designcise/manifest-json 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

designcise/manifest-json

最新稳定版本:v3.1.0

Composer 安装命令:

composer require designcise/manifest-json

包简介

manifest.json parser/loader for PHP

README 文档

README

CI Maintainability Test Coverage

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

License

Please see License File for licensing information.

统计信息

  • 总下载量: 2.61k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-05-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固