如何合并Zend Framework 2模块公共目录 [英] How to merge Zend Framework 2 module public directories

查看:75
本文介绍了如何合并Zend Framework 2模块公共目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

某些zf2模块具有用于分发资源(例如js/css/images)的公共目录.使这些资源可供申请人使用的最佳实践是什么?

Some zf2 modules have public directories for distribution of resources such as js/css/images. What is best practice for making these resouces available to the applicaiton?

我希望它可以通过http://mysite.com/[moduleName]/自动提供这些资源.例如

I would like it so that these resources were automatically available through http://mysite.com/[moduleName]/. For example,

root/public/js/sitescript.js-> http:\\mysite.com\js\sitescript.js

root/module/mymodule/public/js/modulescript.js-> http:\\mysite.com\mymodule\js\modulescript.js

root/vendor/vendormodule/public/js/vendorscript.js-> http:\\mysite.com\vendormodule\js\vendorscript.js

是否应将这些资源复制到根目录/公共目录?手动复制会很痛苦,而且我怀疑自动合并目录的构建过程是否也很实用.

Should these resources be copied to the root/public directory? Manual copying will be painful, and I doubt an automated build process to merge the directories would be very practial either.

也许有些魔术可以与httpd.conf或.htaccess一起使用?

Perhaps there is some magic that can be worked with httpd.conf or .htaccess?

也许符号链接是解决方案?但是,符号链接并不能直接在Windows平台上运行,而是需要为每个单独的模块手动创建.

Perhaps symlinks are the solution? But, symlinks are not straight forward to get going on a Windows platform, and would need to be created manually for each individual module.

推荐答案

有4种处理方式:

  1. public/目录中符号化资产
  2. 将资产从模块复制粘贴到public/目录
  3. 使用特定的虚拟主机配置(或通常是网络服务器配置)
  4. >
  5. 使用资产管理器模块,例如以下之一:

  1. Symlinking assets in the public/ directory
  2. Copy-pasting assets from the modules to the public/ directory
  3. Using a particular Virtual Host Configuration (or generally web-server configuration)
  4. Use an asset-manager module, such as one of the following:

  • AssetManager - backed by assetic - merges assets at runtime, has caching for production environments and filters for CSS/JS minification and LESS/SASS conversion, allows exposing of assets from directories in the modules themselves.
  • zf2-assetic-module - backed by assetic - handles CSS/JS minification and LESS/SASS conversion at runtime
  • BaconAssetLoader - exposes assets from modules by deploying them in the public/ dir at deploy time

这篇关于如何合并Zend Framework 2模块公共目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆