hultberg/mexifest

manifest.json 读取器

v2.0.3 2018-07-10 13:47 UTC

This package is auto-updated.

Last update: 2024-09-18 23:16:33 UTC


README

一个简单的资产管理者,用于解析php的manifest文件。

需要php 7.1。

安装

$ composer require hultberg/mexifest

使用

manifest.json

{
    "app.js": "js/app.js",
    "app.css": "css/app.css"
}

app.php

<?php

require __DIR__ . '/vendor/autoload.php';

use Hultberg\Mexifest\AssetManager;
use Hultberg\Mexifest\WebpackManifestParser;
use League\Flysystem\Adapter\Local as LocalAdapter;
use League\Flysystem\Filesystem;

$fs = new Filesystem(new LocalAdapter(__DIR__));
$am = new AssetManager((new WebpackManifestParser($fs, 'manifest.json'))->parse());

/*
  Output: [
    ['app.js', 'js/app.js', 'js'],
  ]
 */
var_dump($am->findByName('app.js'));

/*
  Output: [
    ['app.css', 'css/app.css'],
  ]
 */
var_dump($am->findByExtension('css'));

许可证

MIT,请参阅仓库中提供的LICENSE.md。