aryelgois/composer-front-end
Composer 安装命令:
composer require aryelgois/composer-front-end
包简介
A utility to install front-end files with Composer
README 文档
README
A utility to install front-end files with Composer
Intro
By default Composer installs all package files under the vendor directory.
It is ok for Composer's main purpose: a tool for dependency management in PHP.
But often, PHP projects involve other languages, like those used in front-end (JavaScript, CSS and their derivatives).
You could use different package managers to deal with each kind of file, but it would be too much work, and I think it is good to have a unified tool.
This is where this package comes in. You will use Composer to fetch repositories containing front-end assets, and this package will symlink them to their appropriate directory.
Install
Run this inside your project:
composer require aryelgois/composer-front-end
In order to avoid Composer warnings during a fresh install, keep the package entry at the beginning of composer.json
requiredirective.
Setup
Add this to your composer.json:
{
"scripts": {
"post-package-install": "aryelgois\\Composer\\FrontEnd::postPackageInstall",
"front-end-refresh": "aryelgois\\Composer\\FrontEnd::refresh"
},
}
Now, whenever you install a new package with front-end files, they will be symlinked.
If you already installed some front-end packages, run
composer front-end-refresh to look in every vendor package.
Config files
These JSON files are used to tell which files should be symlinked and where.
You could use any key you like for the file_group, but it needs to be the same
in the vendor config and in your project.
frontend.json
Used in vendor packages.
It contains a map of 'file_group': ['file'] of files to be symlinked into your
project.
Paths are relative to the vendor package directory.
not
vendor/, butvendor/some/package/
Example:
{
"css": "assets/superduperstyle.css",
"js": [
"main.js",
"src/myawesomescript.js"
]
}
It is possible to specify a single file without an array.
frontend-config.json
Used in your project.
It can include the following keys:
directories
(required)
A map of 'file_group': 'directory' to contain symlinks from other packages.
Paths are relative to the root directory.
packages
(optional)
A map of 'package/name': files to be symlinked. The content would be the same
as in frontend.json.
Useful when a vendor does not include the frontend.json.
It replaces the frontend.json
structure
(optional)
Defines how the symlinks are placed in the directory of each file_group:
- nest: Symlinks will be created at
vendor/package/, inside the specified directories. It helps with files with same name. - flat: Symlinks will stay directly inside the defined directories.
structure_default
(optional)
Defines the default structure for all directories. If not specified, nest is
used.
Example:
{
"directories": {
"css": "public/css",
"js": "public/js"
},
"structure": {
"css": "flat",
}
}
public/is the Document Root
Notes
-
You still need to manually add the markup to use the symlinked files in your webpage:
<head> <link rel="stylesheet" href="/css/superduperstyle.css" /> </head> <body> <script src="/js/some/package/myawesomescript.js"></script> <script src="/js/some/package/main.js"></script> </head> -
Even with
nest, all symlinks are placed flattened, i.e., the file structure in the vendor package is not preserved.
TODO
- Add path expansion for frontend.json
aryelgois/composer-front-end 适用场景与选型建议
aryelgois/composer-front-end 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12.38k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 12 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「composer」 「front-end」 「dependency-manager」 「package-manager」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 aryelgois/composer-front-end 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 aryelgois/composer-front-end 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 aryelgois/composer-front-end 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This composer plugin enables installation of GravityForms WordPress plugin and its addons.
Simple ASCII output of array data
This package helps combine front-end resources (html, js, css) into reusable blocks (modules)
Velocity Apps provides generic applications and controllers used to communicate with backend including CMSGears modules.
Velocity is a JavaScript library which provide utilties, UI components and MVC framework implementation.
统计信息
- 总下载量: 12.38k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-12-11