Publishing Assets from Modules in Zend Framework 2

It is generally recommended that you store module assets inside the module directory, inside moduleName/public (or whatever you want to call the resource directory).

Zend Framework 2, unfortunately, does not support asset publishing for module assets by default. According to the MWOP, nothing was planned ~ 1 month ago, and I think there is still no real plan (they probably had a lot of work to prepare a stable version). (But, one day, they are going to solve this problem.)

As my ZF2 application grows and grows, I have reached the point where I need to have module-specific assets . I currently maintain them inside the module directories and copy them to the application’s shared directory. You can imagine that this method is error prone and exhausting.

How do you deal with this problem? Maybe a simple solution to this problem with a little coding effort? My project plan does not allow me to create complex asset transactions on my own. Is there a recommended, lightweight asset structure compatible with ZF2? I have already considered creating symbolic links, but I don’t think that this would be the best solution, because this would require additional configuration of the web server ( FollowSymlinks ) and additional maintenance work (the application is developed locally and deployed on a remote server).

Thanks in advance.

+3
source share
3 answers

This has been discussed previously in many places, and it boils down to three ways to manage it.

  • Copy and paste assets into the public directory

  • Use symbolic links

  • Use an asset loading module like assetic

A simple solution would be to make the process of copying assets part of the assembly process.

Another question was asked How to combine the common directories of Zend Framework 2 modules for information.

+7
source

I know this is pretty old, but I wanted to add this information to other readers.

Now there is also a module for this that has been fully tested and used (and even depends on) by many modules.

Take a look here: https://github.com/RWOverdijk/AssetManager

Hope this helps.

+5
source

There is also a fourth option. Use the directory alias in the VirtualHost configuration.

+3
source

Source: https://habr.com/ru/post/1445294/


All Articles