notrix/compass-elephant
Composer 安装命令:
composer require notrix/compass-elephant
包简介
A library to manage a compass project with PHP
README 文档
README
A wrapper for the compass binary written in PHP
Requirements
- php >= 5.3
- *nix system with compass installed
Dependencies
for tests
Installation
composer
To install CompassElephant with composer you simply need to create a composer.json in your project root and add:
{
"require": {
"cypresslab/compass-elephant": ">=0.1.0"
}
}
Then run
$ wget -nc http://getcomposer.org/composer.phar $ php composer.phar install
You have now CompassElephant installed in vendor/cypresslab/compasselephant
And an handy autoload file to include in you project in vendor/.composer/autoload.php
pear
Add the Cypresslab channel
$ pear channel-discover pear.cypresslab.net
And install the package. By now CompassElephant is in alpha state. So remember the -alpha in the library name
$ pear install cypresslab/CompassElephant-alpha
On Cypresslab pear channel homepage you can find other useful information
Testing
The library is fully tested with PHPUnit.
Go to the base library folder and run the test suites
$ phpunit
Code style
- CompassElephant follows the Symfony2 Coding Standard
- I'm using gitflow so, if you want to contribute, please send a pull-request on develop branch
How to use
Remember to give the user the right permissions to access the filesystem. If you are using a web server give permissions to both your user and the web server user.
constructor
<?php $project = new CompassProject("/path/to/compass"); // create the base class, only the path is mandatory.... // Here is a full customized project $path = "/path/to/compass"; $name = "blog"; // a project name. Not used in the library...but useful if you have more than one project $binary = new CompassBinary('/usr/local/bin/compass'); // use this to set a custom path for the executable. If blank the library try with "which compass" before showing an error $stalenessChecker = 'finder'; // or native. More on this later $configFile = 'config_prod.rb'; // the name of the ruby config file. Defaults to config.rb $autoInit = false; // if true, when given a folder without a config file inside, CompassElephant will try to initialize a compass project $project = new CompassProject($path, $name, $binary, $stalenessChecker, $configFile, $autoInit); // Here is the full constructor signature /** * Class constructor * * @param string $projectPath the path to the compass project * @param null $name the project name * @param \CompassElephant\CompassBinary|null $compassBinary a CompassBinary instance * @param mixed $stalenessChecker a StalenessCheckerInterface instance * @param string $configFile the compass config file name * @param bool $autoInit whether to call init() on an empty folder project * * @internal param \CompassElephant\CommandCaller $commandCaller a CommandCaller instance */ public function __construct($projectPath, $name = null, CompassBinary $compassBinary = null, $stalenessChecker = null, $configFile = 'config.rb', $autoInit = true) { // ... }
manage a compass project
<?php // if the project do not contains a config file, CompassElephant assumes it isn't initialized. See autoInit parameters for skip this step if (!$project->isInitialized()) { $project->init(); // call the "compass create" command } // return false if the project needs to be recompiled. In other words if you changed something in config.rb, sass or scss files after the last sylesheets generation if (!$project->isClean()) { $project->compile(); // compile the project echo $project->isClean(); // return true now }
Staleness Checker
Compass checks if the project need to be compiled in two different ways:
finder This method uses the awesome Symfony Finder component. It parse the config.rb file for the sass path and for the stylesheet path. Then check if the modification time of the stylesheets comes before the modification of the config file or a sass file. This is the default method.
native uses the command "compass compile --dry-run" and parse the output to see if there are stylesheets not aligned with sass. This method is not so cool because it's really slow. Even by using it only in a dev environment, it adds 400-500 ms of overhead on every check. So use it only if you can't use the finder method
Are you reinventing the wheel?
I use Assetic for my assets...and you should use it too.
But for now the Compass implementation do not work as intended. Assetic is built upon the concept of a single asset compiled. And it's not aware of dependencies
A pull request for assetic is not so easy, because it should change the entire structure of the library. And I know that the author is working on it.
I promise that, when the issue will be adressed, I will delete this library and return to Assetic. By now you can (should) use it to rewrite/uglify the stylesheets generated by CompassElephant. And this is exactly what I'm doing now.
Symfony2
CompassElephantBundle let symfony do the work for you
notrix/compass-elephant 适用场景与选型建议
notrix/compass-elephant 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.25k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 01 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「css」 「compass」 「sass」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 notrix/compass-elephant 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 notrix/compass-elephant 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 notrix/compass-elephant 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Twig extension to insert css as inline styles with a tag
A collection of Compass targets for Phing.
Caching and compression for Twig assets (JavaScript and CSS).
Sass (SCSS) and Compass support for the Yii framework
Integrates CompassElephant into Symfony2
bootstrap-sass is a Sass-powered version of Bootstrap 3, ready to drop right into your Sass powered applications.
统计信息
- 总下载量: 2.25k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 10
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: LGPL-3.0
- 更新时间: 2018-01-25