designcise/manifest-json
Composer 安装命令:
composer require designcise/manifest-json
包简介
manifest.json parser/loader for PHP
README 文档
README
PHP manifest.json parser/loader.
Installing
composer require designcise/manifest-json
Note
Requires PHP 8.0 or later.
Example
use Designcise\ManifestJson\ManifestJson; $manifest = new ManifestJson('path/to/manifest/'); // defaults to `manifest.json` // or $manifest = new ManifestJson('path/to/manifest/my-manifest.json'); $entry = $manifest->get('entry.js'); $metadata = $manifest->getAll(); $css = $manifest->getAllByType('css'); $images = $manifest->getAllByTypes(['jpg', 'png']); $js = $manifest->getAllByKey('*.js'); $criticalJs = $manifest->getAllByKeyBasename('critical-*.js');
API
static from(string $dirOrFile): self
Static method to load manifest.json file from specified directory. If only directory is specified then it is assumed that file name is manifest.json by default, otherwise the specified name is used. For example:
ManifestJson::from('path/to/manifest/'); // defaults to `manifest.json` ManifestJson::from('path/to/manifest/my-manifest.json');
get(string $key): string
Gets the manifest.json metadata for the specified $key.
getAll(): array
Get all entries in the manifest.json file as an array.
getAllByType(string $type): array
Gets all files with the specified file extension (for e.g. css, js, etc.) as an array.
getAllByTypes(array $types): array
Gets all files with the specified file extensions (e.g. ['css', 'js'], etc.) as an array.
getAllByKey(string $key): array
Gets all files that match the specified key. It looks for a full match in the manifest entries' key. It can optionally have wildcard using asterisk (e.g. *.js, *index*, etc.).
getAllByKeyBasename(string $key): array
Gets all files that match the trailing name component of path in the manifest entry's key. It can optionally have wildcard using asterisk (e.g. *.js, index*, etc.).
Tests
To run the tests you can use the following commands:
| Command | Type |
|---|---|
composer test |
PHPUnit tests |
composer style |
CodeSniffer |
composer style-fix |
CodeSniffer Fixer |
composer md |
MessDetector |
composer check |
PHPStan |
Contributing
- File issues at https://github.com/designcise/manifest-json/issues
- Issue patches to https://github.com/designcise/manifest-json/pulls
License
Please see License File for licensing information.
designcise/manifest-json 适用场景与选型建议
designcise/manifest-json 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.69k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2020 年 05 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 designcise/manifest-json 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 designcise/manifest-json 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 2.69k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-05-10