Download the PHP package gin0115/vite-manifest-parser without Composer
On this page you can find all versions of the php package gin0115/vite-manifest-parser. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gin0115/vite-manifest-parser
More information about gin0115/vite-manifest-parser
Files in gin0115/vite-manifest-parser
Package vite-manifest-parser
Short Description A simple parser for Vue 3, VITE asset manifest files.
License MIT
Homepage https://github.com/gin0115/vite-manifest-parser
Informations about the package vite-manifest-parser
A basic parser for vite manifest file, which allows for the including of vue3-cli/vite projects in php.
Install
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
You can then access the assets using the following:
API
ViteManifestParser()
The constructor takes 2 properties:
- assetUri - The base url of the assets.
- manifestPath - Path to the vite manifest file.
getAssetsUri
@return string The base url of the assets.
Returns the defined assetUri with any trailing slash removed.
getAssetsForVueFile
@param string $fileName The name of the vue file.
@return array<string, string|string[]> 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.
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
@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.
Unlike
getAssetsForVueFile()
, this will not throw exceptions if the file doesn't exist and will just return null.
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.
Unlike
getAssetsForVueFile()
, this will not throw exceptions if the file doesn't exist and will just return an empty array.
Change log
- 0.1.0 - Initial release.
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 projectcomposer 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
& 8.1
. On both windows and linux operating systems. Please note the Windows version runs less tests.