cypresslab/less-elephant

A library to manage a less project with PHP

Installs: 4 060

Dependents: 3

Stars: 3

Watchers: 1

Forks: 2

Language: PHP

0.2.5 2013-06-05 21:25 UTC

README

A wrapper for the less binary written in PHP

Requirements

  • php >= 5.3
  • *nix system with less (lessc binary) installed

Dependencies

for tests

Installation

composer

To install LessElephant with composer you simply need to create a composer.json in your project root and add:

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

Then run

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

You have now LessElephant installed in vendor/cypresslab/lesselephant

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 LessElephant is in alpha state. So remember the -alpha in the library name

$ pear install cypresslab/LessElephant-alpha

On Cypresslab pear channel homepage you can find other useful information

Testing

The library is tested with PHPUnit.

Go to the base library folder and run the test suites

$ phpunit

Code style

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 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")
);

manage a less project

// 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

Staleness Checker

LessElephant checks if the project need to be compiled with the awesome Symfony Finder component, by scanning your source less folder

Symfony2

LessElephantBundle let symfony do the work for you