Gabs Gabs - 2 months ago 33
Less Question

Integrate Less/Sass Compiler in Zend Framework 2

I have been researching online but can't really figure out the best way to integrate a less or sass compiler into a zend 2 environment.

I have visited few pages but it is not clear step by step.

I am not aware of which package to download and how to make it useful.

Can anyone help please?

Answer

Are you sure you need a real integration?

These days, I just use something like gulp to compile/concat/minify front-end assets and dump them into my webroot.

In a typical ZF2 project, you'd end up with a structure like:

MyProject/
MyProject/src
MyProject/view
MyProject/public/css
MyProject/public/js
MyProject/frontend/sass
MyProject/frontend/js
MyProject/bower_components

src, view and public are your typical top-level directories.

frontend holds your sources, which gulp processes, dropping artifacts like public/css/styles.css.

bower_components assumes you're using bower to manage frontend dependencies.

None of the above really cares that it's associated with a ZF2 project; it's completely orthogonal, but lives along side the PHP stuff in your VCS repository.