decodelabs / zest
Vite front end dev environment integration
Installs: 1 178
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^8.1
- decodelabs/archetype: ^0.3.6
- decodelabs/clip: ^0.3.4
- decodelabs/collections: ^0.9
- decodelabs/exceptional: ^0.4.3
- decodelabs/genesis: ^0.9
- decodelabs/lucid: ^0.4.7
- decodelabs/overpass: ^0.2.6
- decodelabs/terminus: ^0.10
- decodelabs/veneer: ^0.11.6
Requires (Dev)
- ext-pcntl: *
- decodelabs/phpstan-decodelabs: ^0.6.1
README
Vite front end dev environment integration
Zest provides a simplified and opinionated PHP oriented entry point to the Vite development environment.
Get news and updates on the DecodeLabs blog.
Installation
Install via Composer:
composer require decodelabs/zest
Usage
Zest aims to provide a simple automated way to integrate the Vite dev server into your PHP application.
All terminal commands assume you have Effigy installed and working.
cd my-project
effigy zest init
This command will initialise a Vite config file, install everything you initially need in a package.json file and run the dev server. ctrl+c
to quit the server.
From then on:
# Run the dev server effigy zest dev # Or build the static files effigy zest build
Build will trigger automatically when the dev server is closed.
View consumption
To make use of Zest, you will need to consume the generated assets from the manifest in your views. As it stands, there are no pre-built view adapters (there are many different view libraries out there!!), however you can adapt the one you use like this:
use DecodeLabs\Genesis; use DecodeLabs\Zest\Manifest; class ViewPlugin { public function apply(View $view): void { $manifest = Manifest::load( Genesis::$hub->getApplicationPath() . '/my-theme/manifest.json' ); foreach ($manifest->getCssData() as $file => $attr) { /** * @var string $file - path to file * @var array $attr - array of tag attributes */ $view->addCss($file, $attr); } foreach ($manifest->getHeadJsData() as $file => $attr) { $view->addHeadJs($file, $attr); } foreach ($manifest->getBodyJsData() as $file => $attr) { $view->addFootJs($file, $attr); } if ($manifest->isHot()) { $view->addBodyClass('zest-dev preload'); } } }
Licensing
Zest is licensed under the MIT License. See LICENSE for the full license text.