cypresslab/less-elephant

一个使用PHP管理less项目的库

0.2.5 2013-06-05 21:25 UTC

This package is auto-updated.

Last update: 2024-08-29 04:03:17 UTC


README

PHP编写的less二进制封装器

要求

  • php >= 5.3
  • 安装了less (lessc二进制) 的*nix系统

依赖

用于测试

安装

composer

使用composer安装LessElephant,只需在你的项目根目录中创建一个composer.json文件,并添加

{
    "require": {
        "cypresslab/less-elephant": "<=1.0.0"
    }
}

然后运行

$ wget -nc https://getcomposer.org.cn/composer.phar
$ php composer.phar install

现在LessElephant已安装到vendor/cypresslab/lesselephant

并且有一个方便的自载文件,可以包含到你的项目中vendor/.composer/autoload.php

pear

添加Cypresslab通道

$ pear channel-discover pear.cypresslab.net

并安装包。由于LessElephant目前处于alpha状态,所以请记住库名称中的-alpha

$ pear install cypresslab/LessElephant-alpha

Cypresslab pear通道主页上可以找到其他有用的信息

测试

该库使用PHPUnit进行测试。

进入基本库文件夹并运行测试套件

$ phpunit

代码风格

如何使用

请确保用户有权限访问文件系统。如果您使用的是Web服务器,请给予您的用户和Web服务器用户权限。

构造函数

<?php

$project = new LessProject("/path/to/less/folder", "screen.less", "/path/to/css/screen.css"); // create the base class

// optionally you can pass a project name and a custom LessBinary class
$project = new LessProject(
    "/path/to/less/folder",
    "main_file.less",
    "/path/to/css/file.css",
    "my-awesome-project",
    new LessBinary("/path/to/lessc")
);

管理less项目

// return false if the project needs to be recompiled. In other words if you changed something in any of your less files after the last sylesheets generation
if (!$project->isClean()) {
    $project->compile(); // compile the project
}
echo $project->isClean(); // returns true

陈旧性检查器

LessElephant通过扫描您的源less文件夹,使用惊人的Symfony Finder组件来检查项目是否需要编译

Symfony2

LessElephantBundle让symfony为您完成工作