PHP code example of elboletaire / less-cake-plugin

1. Go to this page and download the library: Download elboletaire/less-cake-plugin library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

elboletaire / less-cake-plugin example snippets


Plugin::load('Less');

public $helpers = ['Less.Less'];

echo $this->Less->less('less/styles.less');
// will result in something like...
<link rel="stylesheet" href="/css/lessphp_8e07b9484a24787e27f9d71522ba53443d18bbd2.css" />

echo $this->Less->less(['less/myreset.less', 'less/styles.less']);
// They will be compiled in the same file, so the result will be the same as the previous one
<link rel="stylesheet" href="/css/lessphp_e0ce907005730c33ca6ae810d15f57a4df76d330.css"/>

$this->Html->css('/less/styles.less?', ['block' => true, 'rel' => 'stylesheet/less']);

echo $this->Less->fetch();
echo $this->fetch('css');

echo $this->Less->less('less/styles.less', [
    'js' => [
        // options for lessjs (will be converted to a json object)
    ],
    'parser' => [
        // options for less.php parser
    ],
    // The helper also has its own options
]);
// Same if using the fetch method, but the options are as first param:
echo $this->Less->fetch(['js' => []]);

echo $this->Less->less('less/styles.less', ['js' => ['env' => 'development']]);

echo $this->Less->less('Bootstrap.less/styles.less');
// or...
echo $this->Less->less('/Bootstrap/less/styles.less');
// both will load plugins/Bootstrap/webroot/less/styles.less file

// Get the link to the resulting file after compressing
$css_link = $this->Less->less('less/styles.less', [
    'tag'   => false
]);

// Get the compiled CSS (raw)
$compiled_css = $this->Less->less('less/styles.less', [
    'cache' => false,
    'tag'   => false
]);

echo $this->Less->less('less/styles.less', [
  'parser' => ['compress' => false]
]);

echo $this->Less->less(['less/styles.less'], [], ['bgcolor' => 'magenta']);
echo $this->Less->fetch([], ['bgcolor' => 'magenta']);
// Will overwrite any @bgcolor found in styles.less to #f0f