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?

1 answer 1

Described on the example of PHPixie 3

  1. You must first connect leafo / lessphp using composer.

  2. Put the less-less theme file in bundles \ app \ assets \ templates \ less \ theme.less

    @import "theme_header.less"; @import "theme_footer.less"; .... 
  3. 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'); } } 
  4. 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', ); } 
  5. 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: