PHPackages                             gin0115/vite-manifest-parser - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. gin0115/vite-manifest-parser

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

gin0115/vite-manifest-parser
============================

A simple parser for Vue 3, VITE asset manifest files.

0.1.0(3y ago)068[1 issues](https://github.com/gin0115/vite-manifest-parser/issues)MITPHPPHP &gt;=7.2.0

Since Jul 25Pushed 3y ago1 watchersCompare

[ Source](https://github.com/gin0115/vite-manifest-parser)[ Packagist](https://packagist.org/packages/gin0115/vite-manifest-parser)[ Docs](https://github.com/gin0115/vite-manifest-parser)[ RSS](/packages/gin0115-vite-manifest-parser/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (4)Versions (4)Used By (0)

[![GitHub_CI](https://github.com/gin0115/vite-manifest-parser/actions/workflows/cli.yaml/badge.svg)](https://github.com/gin0115/vite-manifest-parser/actions/workflows/cli.yaml)[![GitHub release (latest SemVer including pre-releases)](https://camo.githubusercontent.com/26a1aadff6cc9c30c5998c6d7f05317e7c4b672901a2c10cd9440d39367c26fc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f67696e303131352f766974652d6d616e69666573742d7061727365723f696e636c7564655f70726572656c6561736573)](https://camo.githubusercontent.com/26a1aadff6cc9c30c5998c6d7f05317e7c4b672901a2c10cd9440d39367c26fc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f67696e303131352f766974652d6d616e69666573742d7061727365723f696e636c7564655f70726572656c6561736573)[![](https://github.com/vite-manifest-parser/workflows/GitHub_CI/badge.svg " ")](https://github.com/vite-manifest-parser/workflows/GitHub_CI/badge.svg)[![codecov](https://camo.githubusercontent.com/91457cddfbb4aef8aa479d2116de05fb81395d9ce08b564dc194930871cb5dbd/68747470733a2f2f636f6465636f762e696f2f67682f67696e303131352f766974652d6d616e69666573742d7061727365722f6272616e63682f6d61696e2f67726170682f62616467652e7376673f746f6b656e3d314932554a5737313748)](https://codecov.io/gh/gin0115/vite-manifest-parser)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/bcb4b2e7a61e3ce0b977a101a19bfb988717c04e6a01d2a1e1bea94272ff900f/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f67696e303131352f766974652d6d616e69666573742d7061727365722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d61696e)](https://scrutinizer-ci.com/g/gin0115/vite-manifest-parser/?branch=main)[![GitHub issues](https://camo.githubusercontent.com/a4e499b08adfcbb7a315e2b46a417cfc91ff5b7eabe530ff3b2e1ddea525a853/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f67696e303131352f766974652d6d616e69666573742d706172736572)](https://github.com/gin0115/vite-manifest-parser/issues)![Open Source Love](https://camo.githubusercontent.com/2d4eac62d5f5830a5309100b88e0ecccb171aee1fbcd794149f4a580b0010c56/68747470733a2f2f6261646765732e66726170736f66742e636f6d2f6f732f6d69742f6d69742e7376673f763d313032)

A basic parser for vite manifest file, which allows for the including of vue3-cli/vite projects in php.

Install
=======

[](#install)

```
composer require gin0115/vite-manifest-parser
```

Usage
=====

[](#usage)

To accommodate the random hash which is added to assets compiled for `vue 3` using `vite` , this library allows for the easy parsing of the required assets.

> Example Vite Manifest

```
{
  "main.js": {
    "file": "assets/main.4889e940.js",
    "src": "main.js",
    "isEntry": true,
    "dynamicImports": ["views/foo.js"],
    "css": ["assets/main.b82dbe22.css"],
    "assets": ["assets/asset.0ab0f9cd.png"]
  },
  "views/foo.js": {
    "file": "assets/foo.869aea0d.js",
    "src": "views/foo.js",
    "isDynamicEntry": true,
    "imports": ["_shared.83069a53.js"]
  },
  "_shared.83069a53.js": {
    "file": "assets/shared.83069a53.js"
  }
}
```

You can then access the assets using the following:

```
$manifest = new ViteManifestParser('https://www.url.tld/dist', 'path/to/project/vite.json');

// To access the main.js file url
// Just pass in the file name.
$mainJsUrl = $manifest->getEntryScriptUri('main.js');

// Returns https://www.url.tld/dist/assets/main.4889e940.js

// To access all CSS files.
$cssFiles = $manifest->getEntryCssUris('main.js');

// Returns [
//   'https://www.url.tld/dist/assets/main.b82dbe22.css'
// ];
```

API
===

[](#api)

ViteManifestParser()
--------------------

[](#vitemanifestparser)

The constructor takes 2 properties:

- assetUri - The base url of the assets.
- manifestPath - Path to the vite manifest file.

```
$parser = new ViteManifestParser('https://www.url.tld/dist', 'path/to/project/vite.json');

// This can also be used to set the base path, based on the environment.
$assetUrl = App::environment('local')
    ? 'http://localhost:8080/dist'
    : 'https://www.url.tld/dist';

$parser = new ViteManifestParser($assetUrl, 'path/to/project/vite.json');
```

getAssetsUri
------------

[](#getassetsuri)

> @return string The base url of the assets.

Returns the defined assetUri with any trailing slash removed.

```
$parser = new ViteManifestParser('https://www.url.tld/dist/', 'path/to/project/vite.json');

$parser->getAssetsUri(); // Returns 'https://www.url.tld/dist'
```

getAssetsForVueFile
-------------------

[](#getassetsforvuefile)

> @param string $fileName The name of the vue file.
> @return array&lt;string, string|string\[\]&gt; The assets for the vue file.
> @throws \\Exception - File does not exist in manifest.
> @throws \\Exception - File assets are empty or invalid.

 File Asset properties - **file**: *string*
- **src**: *string*
- **isEntry**?: *bool* (optional)
- **isDynamicEntry**?: *bool* (optional)
- **dynamicImports**?: *string\[\]* (optional)
- **css**?: *string\[\]* (optional)
- **assets**?: *string\[\]* (optional)
- **imports**?: *string\[\]* (optional)

Returns an array of all details defined in the manifest for the given vue file.

```
$parser = new ViteManifestParser('https://www.url.tld/dist', 'path/to/project/vite.json');

$fileDetails = $parser->getAssetsForVueFile('main.js');

/*
 * "file => "assets/main.4889e940.js",
 * "src => "main.js",
 * "isEntry => true,
 * "dynamicImports => ["views/foo.js"],
 * "css => ["assets/main.b82dbe22.css"],
 * "assets => ["assets/asset.0ab0f9cd.png"]
 */
```

> This will throw exceptions if there is an issue with the manifest file it self or the required file from manifest doesn't exist.

getEntryScriptUri
-----------------

[](#getentryscripturi)

> @param string $fileName - The filename of the asset
> @return string|null - The url of the asset or null if file doesn't exist.

This will return just the main JS file uri, this will be prepended with the assetUri.

```
$parser = new ViteManifestParser('https://www.url.tld/dist', 'path/to/project/vite.json');

$mainJsUrl = $parser->getEntryScriptUri('main.js');

// Returns https://www.url.tld/dist/assets/main.4889e940.js
```

> Unlike `getAssetsForVueFile()` , this will not throw exceptions if the file doesn't exist and will just return null.

getEntryCssUris
---------------

[](#getentrycssuris)

> @param string $fileName - The filename of the asset
> @return string\[\] - The urls of the css assets.

This will return all css files that are defined for the entry file. This will be prepended with the assetUri.

```
$parser = new ViteManifestParser('https://www.url.tld/dist', 'path/to/project/vite.json');

$cssFiles = $parser->getEntryCssUris('main.js');

// Returns [
//   'https://www.url.tld/dist/assets/main.b82dbe22.css'
// ];
```

> Unlike `getAssetsForVueFile()` , this will not throw exceptions if the file doesn't exist and will just return an empty array.

Change log
==========

[](#change-log)

- 0.1.0 - Initial release.

Contributing
============

[](#contributing)

If you would like to contribute to this project, please open an issue or pull request. All pull requests must pass the testing suite of PHPUnit, PHPStan and PHP Code Sniffer. To run these tests please run the following.

- `composer coverage` - Runs the PHPUnit test cases and will create a HTML coverage report (if you have a valid coverage driver installed)
- `composer test` - Runs the PHPUnit test cases without the coverage report.
- `composer sniff` - Runs PHP Code Sniffer on the project.
- `composer fixer` - Runs PHPCBF against the files to the defined rules (PSR12).
- `composer analyse` - Runs the PHPStan ruleset for the project
- `composer all` - Runs all of the above and is what is run as part of the GH Action pipeline.

All code must pass all of these suites against php versions `7.2` , `7.3` , `7.4` , `8.0` &amp; `8.1` . On both windows and linux operating systems. Please note the Windows version runs less tests.

###  Health Score

19

—

LowBetter than 9% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1440d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d82b9e8ef7816d3d0b9812ad233f61f6a313f529e0ac85721781b46ad292e1ea?d=identicon)[glynnquelch](/maintainers/glynnquelch)

---

Top Contributors

[![gin0115](https://avatars.githubusercontent.com/u/28779094?v=4)](https://github.com/gin0115 "gin0115 (51 commits)")

---

Tags

vitevuevue3vue-clivue-manifest-parservue-asset-manifest-parservue-asset-manifest-parser-for-vite

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/gin0115-vite-manifest-parser/health.svg)

```
[![Health](https://phpackages.com/badges/gin0115-vite-manifest-parser/health.svg)](https://phpackages.com/packages/gin0115-vite-manifest-parser)
```

###  Alternatives

[pentatrion/vite-bundle

Vite integration for your Symfony app

2766.8M25](/packages/pentatrion-vite-bundle)[ijpatricio/mingle

Use Vue and React in Laravel Livewire Applications.

43970.0k2](/packages/ijpatricio-mingle)[nystudio107/craft-vite

Allows the use of the Vite.js next generation frontend tooling with Craft CMS

54323.8k45](/packages/nystudio107-craft-vite)[arnoson/kirby-vite

Vite helper for Kirby CMS

9765.1k3](/packages/arnoson-kirby-vite)[idleberg/wordpress-vite-assets

Injects assets from a Vite manifest to the Wordpress head, supports themes and plugins

14917.7k2](/packages/idleberg-wordpress-vite-assets)[nystudio107/craft-plugin-vite

Plugin Vite is the conduit between Craft CMS plugins and Vite, with manifest.json &amp; HMR support

13995.6k65](/packages/nystudio107-craft-plugin-vite)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
