Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Asset Collection!


I am trying to use Css an Js asset collection in the ControllerBase initialize function. So far everything is fine, but when I try to use the collection in the .volt file I always get the error that the collection is not known in the manager.

Here the code: ControllerBase.php

class ControllerBase extends \Phalcon\Mvc\Controller
     * Execute before the router so we can determine if this is a private controller, and must be authenticated, or a
     * public controller that is open to all.
     * @param Dispatcher $dispatcher
     * @return boolean
    public function initialize()
             ->addCss('third-partyassets/plugins/fullcalendar/fullcalendar.css', false, false)
             ->addCss('third-party/assets/plugins/assets/css/custom-icon-set.css', false, false)
             ->addCss('assets/css/custom-icon-set.css', false, false)
             ->addFilter(new \Phalcon\Assets\Filters\Cssmin());

.volt File

{{ this.assets.outputCss('cssStyle') }}

When I try to use the following code in the index.php the collection gets recognized. Where is my error??????



when and how are you registering the assets?



First of all, you don't need to register the asset manager in the DI and {{ assets.outputCss(cssStyle) }} is enough.

Then, I think your code is wrong, because second argument should be set to true if your css files are hosted on the same server (see, it works in your second configuration, and not because it is registred in the DI).

More here:


Thanks for the replies and hints for a better code. I found the problem. I overwrote the initialize function in a different controller.