A very simple plugin for using phpless (a LESS php implementation) in CakePHP
PHP
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Controller
Model
Vendor
webroot
.gitmodules
composer.json
license.txt
readme.md

readme.md

Cakeless - A very simple lessphp plugin for CakePHP

This plugin is a very simple implementation of lessphp for CakePHP 2.x. (check 1.3 branch for CakePHP 1.3.x)

To use Cakeless download and unzip the plugin or clone git repository in plugins/cakeless.

Using the plugin

In your Controllers or App Controller

Load plugin in bootstrap.php (for CakePHP 2.x):

CakePlugin::load('Cakeless');

Include the component using:

public $components = array('Cakeless.Cakeless');

Indicate the .less file you want to compile and the desired location and filename for the compiled file. For example:

$lessExample = APP . 'plugins' . DS . 'cakeless' . DS . 'webroot' . DS . 'less' . DS . 'example.less';
$cssExample = APP . 'plugins' . DS . 'cakeless' . DS . 'webroot' . DS . 'css' . DS . 'example.css';

$this->Cakeless->compile( $lessExample, $cssExample );

This will compile the provided example file (/app/plugins/cakeless/webroot/less/example.less) to /app/plugins/cakeless/webroot/css/example.css. This could be used for testing purposes but you may want to see a more real life example. Here you have it:

$lessMainStyles = WWW_ROOT . 'less' . DS . 'main_styles.less';
$cssMainStyles = WWW_ROOT . 'css' . DS . 'main_styles.css';

$this->Cakeless->compile( $lessMainStyles, $cssMainStyles );

IMPORTANT NOTE: Compilation will only occur under debug modes 1 and above of your CakePHP application.

In your Views

Simply link to the CSS file as usual:

echo $this->Html->css( 'main_styles', null, array( 'media' => 'screen, projection' ) );

Requirements

  • PHP version: PHP 5.2+
  • CakePHP version: Cakephp 2.x Stable
  • lessphp version: 0.3.5 (no need to download, included in /vendors folder)

Support

For support and feature request, please use the repository Issues section at GitHub.

About LESS and lessphp

If you want to know more about LESS syntax please check the official LESS documentation. For lessphp extended documentation and downloads please visit the official lessphp website.

License

Copyright (c) 2011 Sebastián Veggiani, http://actionauta.com

Licensed under The MIT License (MIT)
Redistributions of files must retain the above copyright notice.

Copyright

Copyright 2011
Sebastián Veggiani