Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony2 minify without java or node

Tags:

minify

symfony

I do not have access to java or node on my shared host. Is there a way to minify server side, so I can continue to use assetic, without these engines? Uglify uses node and yui-compressor (deprecated anyway) uses java.

Thanks!

like image 596
Brandon Avatar asked Aug 24 '13 00:08

Brandon


2 Answers

There seem to be 2 filters using only PHP code:

  • CssMinFilter
  • JSMinPlusFilter

You will need to install the minify php library through composer, and then use the cssmin and jsminplus assetic filters.

like image 110
AdrienBrault Avatar answered Nov 09 '22 10:11

AdrienBrault


Just for clarify the steps:

  1. composer require mrclay/minify
  2. In symfony app/config/config.yml add to assetic config:

    # some stuff assetic: filters: # possible another filters minifycsscompressor: ~ jsminplus: ~

    1. In twig:

    {% stylesheets <your assets> filter='minifycsscompressor' %} <link rel="stylesheet" href="{{ asset_url }}"> {% endstylesheets %}

    {% javascripts <your assets> filter='jsminplus' %} <script src="{{ asset_url }}"></script> {% endjavascripts %}

like image 37
userlond Avatar answered Nov 09 '22 12:11

userlond