daiki52 / fuel-vue
FuelPHP package for integrating Vite/Vue/Inertia assets.
Requires
- php: >=7.0
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
A FuelPHP adapter for integrating Vue.js 3 into existing applications. It aims to make it straightforward to build modern, reactive user interfaces on top of FuelPHP while keeping your current server-side routing and controller patterns.
This library is inspired by @inertiajs/inertia-vue3. We also hope it can serve as a practical stepping stone for teams that want to modernize incrementally and, where appropriate, ease a future migration to modern frameworks such as Laravel.
Motivation
Many production systems still run on FuelPHP, while frontend expectations have shifted toward Vue.js 3, Vite, and component-driven development. This adapter is designed to help you adopt that modern frontend workflow without requiring an immediate full rewrite or a hard switch to a different backend framework.
Features
- Easy integration of Vue.js 3 components into FuelPHP
- Inertia-style development experience (page-driven UI) with FuelPHP
- Flexible configuration options
- Designed to be compatible with existing FuelPHP applications
- Supports incremental adoption (partial replacement and coexistence with server-rendered views)
Requirements
- PHP: 7.0 ~ 7.4
- FuelPHP: 1.8 (Recommended)
- Vite is required for building and bundling your Vue.js components
Installation
composer require daiki52/fuel-vue
Vite asset configuration
By default, Fuel Vue reads build/manifest.json and hot from FuelPHP's
DOCROOT. The generated asset URLs start with /build/, preserving the
conventional FuelPHP setup.
Applications that expose assets from another physical public directory can configure the filesystem root independently from the browser URL:
FuelVue\FuelVue::usePublicPath('/var/www/public_common'); FuelVue\FuelVue::useBuildDirectory('assets/common/build');
This configuration reads the manifest from
/var/www/public_common/assets/common/build/manifest.json and generates URLs
such as /assets/common/build/assets/app-abc123.js.
The available Vite asset configuration methods are:
| Method | Purpose |
|---|---|
usePublicPath($path) |
Set the physical root used to locate Vite files. |
publicPath($path = '') |
Resolve a physical path under the configured public root. |
useBuildDirectory($directory) |
Set the build directory relative to the public root. |
useManifestFilename($filename) |
Set the manifest filename. |
manifestPath() |
Resolve the configured manifest's physical path. |
useHotFile($path) |
Set an explicit physical path for the hot file. |
hotFile() |
Resolve the configured or default hot file path. |
createAssetPathsUsing($resolver) |
Customize browser-facing asset URLs. |
For example, a project that uses a non-default manifest filename can configure it independently from the build directory:
FuelVue\FuelVue::useManifestFilename('assets.json');
The hot file defaults to hot under the configured public path. It can be
placed elsewhere when the Vite development server and PHP application share a
different runtime directory:
FuelVue\FuelVue::useHotFile('/var/run/my-app/vite.hot');
The Node-side Vite plugin must use the same paths:
fuelViteConfig({ rootDir: __dirname, publicDirectory: 'public_common', buildDirectory: 'assets/common/build', hotFile: 'public_common/hot', input: ['resources/js/app.ts'], })
Asset URLs are root-relative by default. A custom resolver can generate CDN or application-specific URLs without changing where the manifest is read:
FuelVue\FuelVue::createAssetPathsUsing(function ($path, $secure = null) { return 'https://cdn.example.com/'.ltrim($path, '/'); });
The following compatibility methods remain available but are deprecated:
| Deprecated | Replacement |
|---|---|
useBuildDir() |
useBuildDirectory() |
useManifestFile() |
useManifestFilename() |
public_path() |
publicPath() |
manifest_path() |
manifestPath() |
Testing
composer test