Attention! This question is a translation of the question: How to compile files?
I want to use a compilation of less-files for bootstrap 3 in the PHPixie project.
How can this be done using the PHPixie console command?
Attention! This question is a translation of the question: How to compile files?
I want to use a compilation of less-files for bootstrap 3 in the PHPixie project.
How can this be done using the PHPixie console command?
Described on the example of PHPixie 3
You must first connect leafo / lessphp using composer.
Put the less-less theme file in bundles \ app \ assets \ templates \ less \ theme.less
@import "theme_header.less"; @import "theme_footer.less"; .... Create the class bundles \ app \ src \ Console \ CompileLess.php of the following form:
<?php namespace Project\App\Console; use PHPixie\Console\Command\Config; use PHPixie\Slice\Data; /** * Сonsole command to compile less to css */ class CompileLess extends Command { /** * Configure your command * @param Config $config */ protected function configure($config) { $config->description("Compile less to css"); } /** * @param Data $argumentData * @param Data $optionData */ public function run($argumentData, $optionData) { $lessphp = new \lessc; $less_dir =$this->builder->assetsRoot()->path().'/templates/less/'; $css_dir = $this->builder->webRoot()->path(); $lessphp->compileFile($less_dir.'theme.less', $css_dir.'theme.css'); } } And write it in bundles \ app \ src \ Console.php:
<?php namespace Project\App; class Console extends \PHPixie\DefaultBundle\Console { protected $classMap = array( 'greet' => 'Project\App\Console\Greet', 'compileLess' => 'Project\App\Console\CompileLess', ); } After that we can see the command in the list of available if we start the console without parameters and run:
console app:compileLess Useful links:
Source: https://ru.stackoverflow.com/questions/715446/
All Articles