PHP manifest.json
parser/loader.
composer require designcise/manifest-json
Note
Requires PHP 8.0 or later.
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');
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');
Gets the manifest.json
metadata for the specified $key
.
Get all entries in the manifest.json
file as an array.
Gets all files with the specified file extension (for e.g. css
, js
, etc.) as an array.
Gets all files with the specified file extensions (e.g. ['css', 'js']
, etc.) as an 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.).
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.).
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 |
- File issues at https://github.com/designcise/manifest-json/issues
- Issue patches to https://github.com/designcise/manifest-json/pulls
Please see License File for licensing information.