We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How to setup a minify CSS or JS in Phalcon?

I'm following this tutorial: https://docs.phalcon.io/en/latest/reference/assets.html

And this is my implement code:

$this->assets
    ->collection('header')
    ->addCss($config->static->url . '/css/font-awesome.min.css', false)
    ->addCss($config->static->url . '/css/bcdcnt.css', false)
            ->setTargetPath('final.css')
            ->join(true)
            ->setTargetUri('index/final.css')
    ->addFilter(new Phalcon\Assets\Filters\Cssmin());

In my view:

{{ assets.outputCss('header') }}

And the result:

<link rel="stylesheet" type="text/css" href="/index/final.css">

But when clicking in the generated link "/index.final.css", it says that:

Action 'final.css' was not found on handler 'index'

So my question is that how to set up a minify CSS or JS using asset built in featued of Phalcon?



43.9k
edited Aug '14

everything looks good in your code except:

->setTargetUri('index/final.css')

you have to correct that