fredjuvaux/silex-less-provider

Simple less php service provider for Silex

dev-master 2015-05-30 23:43 UTC

This package is not auto-updated.

Last update: 2024-04-23 00:43:01 UTC


README

Simple less php service provider for Silex that uses https://github.com/leafo/lessphp as parser.

You'll find the following topics in this README:

Dependencies

Installation

You basically have three options to add this extension to your Silex project. We'd strongly recommend the first option!

composer.json

http://packagist.org/packages/fredjuvaux/silex-less-provider

php composer.phar require fredjuvaux/silex-less-provider dev-master

Or add to the dependencies in your projects composer.json file and update your dependencies::

"fredjuvaux/silex-less-provider": "dev-master"
php composer.phar update

This is by far the easiest way, since it automatically adds the Doctrine dependencies and adds everything to the autoloading mechanism supplied by Composer.

More information on Composer can be found on getcomposer.org.

Git

Another option is to clone the project:

cd /path/to/your_project/vendor
git clone git@github.com:fredjuvaux/silex-less-provider.git

Or you can add it as a submodule if your project is in a git repository too:

cd /path/to/your_project
git submodule add git@github.com:fredjuvaux/silex-less-provider.git

This will require you to manually install all the dependencies. Also note that you'll need to add the provider to the Silex autoloader (or whatever autoloading mechanism) by hand. More on both subjects can be found below.

Download an archive

GitHub also gives you the option to download an ZIP-archive, which you can extract in your vendor folder. This method will also require you to manually install all the dependencies and add everything to your autoloader.

Configuration

Registering the Less Service Provider is rather straight forward:

<?php

/* ... */

use Less\Provider\LessServiceProvider;

$app->register(new LessServiceProvider(), array(
    'less.source_dir'   => array(__DIR__.'/../web/less/'), // specify one or serveral directories for sources
    'less.cache_dir'    => __DIR__.'/../var/cache/', // specify one directory for caching files
    'less.target_dir'   => __DIR__.'/../web/css/', // specify one directory for compiled files
));

Use

The Less files have to be in sources directories. The files are cached and regenerated if it's needed.
In the Twig view, you have to call the css generated files (in less.target_dir).