hultberg/mexifest

A manifest.json reader

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

This package is auto-updated.

Last update: 2024-10-18 23:29:46 UTC


README

A simple asset manager that parses manifest files for php.

Requires php 7.1.

Install

$ composer require hultberg/mexifest

Usage

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'));

License

MIT, see LICENSE.md provided in repo.