Search code examples
phpassetslaravel-bladephalcontemplate-engine

How to add assets in Phalcon framework with Blade template engine?


A started to work with Phalcon framework, included Blade templating. It's already works, but unfortunately i didn't find the right way to include css and JS assets in master.blade.php. If I add the assets like $this->assets->addCss("css/bootstrap.min.css"); in the controller I can not include it in the master template file.

For example, my indexAction looks like this:

public function indexAction(){  
    $this->assets->addCss("css/bootstrap.min.css");
    $this->assets->addJs("js/bootstrap.min.js");
    return $this->blade->make('index.index');  
}

Thanks for any help!


Solution

  • Well - you should add blade as actual template engine into phalcon view.

    Your class should extends Engine implements EngineInterface. If you will do it it could be nice to add it to incubator repository.

    https://github.com/phalcon/incubator/tree/master/Library/Phalcon/Mvc/View/Engine check out implementation of other engines for more how are they made. Then you could just do {{ assets.outputJss() }}, example from volt/twig, not sure how exactly it should look like in blade, never used it.

    Also what's wrong with volt? It's faster than blade and have many features.