wearejh/statics-merger
Composer 安装命令:
composer require wearejh/statics-merger
包简介
A composer plugin that symlinks static assets into the JH Magento Skeleton
README 文档
README
A composer plugin aimed to simplify the workflow between the frontend and backend development teams. Static repositories that the frontend team use are added as a composer dependency to the project as type static.
The plugin hooks onto two composer commands install and update in which on completion will symlink all static packages as defined in their composer.json file.
Installation
This module is installable via Composer. If you have used the Magento Skeleton as a base module then you can just require this project and all the rest is done for you.
Magento 1
$ cd project-root $ ./composer.phar require "wearejh/statics-merger:^2.0.0"
Magento 2
$ cd project-root $ ./composer.phar require "wearejh/statics-merger:^3.0.0"
Upgrading 1.x to 2.x ?
It's recommended to first run composer update statics-merger --no-plugins after changing your composer.json and then run a composer update nothing to map the new configuration.
Note: Depending on the configuration changes you may also have to manually cleanup any remaining symlinks from the old mappings
Usage
Statics project
If the composer.json file is not already there, create one with relevant information and commit it to the repo.
For this to work the statics repository requires the composer.json to have the type set to static.
Example Static Composer.json
{
"name": "wearejh/{project-name}-static",
"type": "static",
"description": "Main theme for {project-name}",
"keywords": ["jh", "statics"],
"authors": [
{
"name": "JH",
"email": "hello@wearejh.com",
"homepage": "http://www.wearejh.com"
}
]
}
Magento project
Within your projects composer.json you will need to ensure you have a few configurations set up.
In your require you will need to add any statics that you want and if private also add the repo.
Note: It's great at handling multiple static repositories 👍
"require": { "wearejh/{project-name}-static": "dev-master" }, "repositories": [ { "type": "git", "url": "git@jh.git.beanstalkapp.com:/jh/{project-name}-static.git" } ]
In your extra you need the magento-root-dir set correctly and have defined the static-map for each static repository.
"extra":{ "magento-root-dir": "htdocs/", "static-map" : { "wearejh/{project-name}-static": { "package/theme": [ { "src": "public/assets", "dest": "assets" }, { "src": "public/assets/img/favicon*", "dest": "/" }, { "src": "assets/images/catalog", "dest": "images/catalog" } ] } } }
The first key is the name of the repository which you have used in the require section, while inside there each key is the package/theme in which the example would map to skin/frontend/package/theme within your `magento-root-dir.
The package/theme array contains several objects defining the src and dest of the files. The src value is relevant to the root of the statics repository while the dest is relevant to the package/theme defined in the Magento project such as skin/frontend/package/theme/ within your magento-root-dir.
Need to map a static repo to more than 1 package or theme? No problem just add another package/theme array to your repos mappings, of course make sure you use a different name to any others to avoid overwriting.
Valid Mappings
Note: Globs require the dest to be a folder and not a file, whereas files and directories need to point to there corresponding full path which allows you to rename them if required. If you leave the dest blank on a glob it will map to the same source directory structure within your package/theme
Files
Link an image into a different directory structure and rename
{
"src": "public/assets/img/awesome/cake.gif",
"dest": "images/newcake.gif"
}
Directories
Linking a whole directory keeping all sub-dirs & files
{
"src": "public/assets",
"dest": "assets"
}
Globs
You can also use globs which makes it pretty awesome! A great use case for this is favicons where you could have multiple at different resolutions with a set naming convention. To target them all you would simply use favicon* like in the default example below.
All favicons to root dir skin/frontend/package/theme/
{
"src": "favicon*",
"dest": "/"
}
Final Notes
- Use tags to explicitly pull in the static repositories
- Don't forget to add the
package/themedir to your.gitignoreotherwise you will add the statics files to the Magento repo, and everyone will hate you - You can amend statics directly from the
vendordir and push straight to the main repo, WIN! - Have fun !! 😄
Problems?
If you find any problems or edge cases which may need to be accounted for within this composer plugin just open up an issue with as much detail as possible so it can be recreated.
Running Tests
$ cd vendor/wearejh/statics-merger
$ php composer.phar install
$ ./vendor/bin/phpunit
wearejh/statics-merger 适用场景与选型建议
wearejh/statics-merger 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12.31k 次下载、GitHub Stars 达 9, 最近一次更新时间为 2015 年 05 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「plugin」 「composer」 「composer-plugin」 「statics」 「jh」 「merger」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 wearejh/statics-merger 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 wearejh/statics-merger 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 wearejh/statics-merger 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
CakePHP 4.x AdminLTE Theme.
Composer plugin for preserving custom paths and supporting nested packages
Composer plugin
This composer plugin enables installation of GravityForms WordPress plugin and its addons.
Composer plugin that automatically creates directories defined in your composer.json.
统计信息
- 总下载量: 12.31k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 9
- 点击次数: 20
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-05-14