Cakeless - A very simple lessphp plugin for CakePHP
This plugin is a very simple implementation of lessphp for CakePHP 2.x., (*1)
To use Cakeless download and unzip the plugin or clone git repository in plugins/cakeless
., (*2)
Using the plugin
In your Controllers or App Controller
Load plugin in bootstrap.php (for CakePHP 2.x):, (*3)
CakePlugin::load('Cakeless');
Include the component using:, (*4)
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:, (*5)
$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:, (*6)
$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., (*7)
In your Views
Simply link to the CSS file as usual:, (*8)
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., (*9)
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., (*10)
License
Copyright (c) 2011 Sebastián Veggiani, http://actionauta.com, (*11)
Licensed under The MIT License (MIT)br/
Redistributions of files must retain the above copyright notice., (*12)
Copyright
Copyright 2011br/
Sebastián Veggianibr/, (*13)