laravel/nova-devtool
Nova Devtool streamlines Laravel Nova component development with a Workbench-based Nova setup, one-command installs for common frontend deps, and easy toggles to enable/disable Vue DevTools in Nova’s compiled assets.
Installation:
composer require --dev laravel/nova-devtool
npm install --save-dev @laravel/nova-devtool
Add the package to your composer.json under require-dev and install the NPM dependency.
First Use Case:
Run the nova:devtool setup command to scaffold a Workbench-based Nova environment:
php vendor/bin/testbench nova:devtool setup
This creates a workbench directory with a minimal Nova setup, including:
Serve Nova:
composer run serve
Access Nova at http://localhost:8000/nova (or your configured port).
Isolated Development:
Use the workbench directory to develop Nova components (e.g., cards, fields, toolsets) without affecting your main application. Leverage Orchestra Workbench for:
.env files).Workflow:
nova:devtool setup once per project.workbench/resources/js/nova or workbench/app/Nova.composer run serve to preview changes in real-time.workbench to your main project.Automated Install:
Run nova:devtool install to add common Nova dependencies:
workbench/package.json.Customization:
Extend workbench/webpack.mix.js to add custom Webpack configurations (e.g., Babel plugins, aliases).
Nova Resources:
Create a new resource in workbench/app/Nova/Resources:
php artisan nova:resource Post
Use the Workbench environment to test CRUD operations.
Vue Components:
Develop custom Vue components in workbench/resources/js/nova/Components. Example:
// workbench/resources/js/nova/Components/ExampleField.vue
Nova.field.extend('ExampleField', {
// Field logic
});
Register the component in workbench/resources/js/nova.js:
Nova.booting((Vue, router) => {
Vue.component('example-field', require('./Components/ExampleField'));
});
Tool Integration:
Build custom Nova tools in workbench/app/Nova/Tools. Example:
php artisan nova:tool ExampleTool
Workbench Isolation:
workbench do not reflect in your main project. Manually copy files (e.g., resources/js/nova) to your production app.rsync -avz workbench/resources/js/nova/ ./resources/js/
NPM Dependency Conflicts:
nova:devtool install may override existing package.json dependencies.workbench/package.json before merging changes.Vue DevTools Misconfiguration:
@vue/devtools is installed and workbench/webpack.mix.js includes:
mix.js('resources/js/nova.js', 'public/js')
.vue()
.postCss('resources/css/nova.css', 'public/css', []);
Database Seed Issues:
php artisan tinker
>>> \App\Models\User::factory()->create(['email' => 'nova@laravel.com']);
Nova Logs:
Check workbench/storage/logs/nova.log for errors during development.
Browser Console:
Use composer run serve --hot for live reloading and inspect Vue components in Chrome DevTools.
API Debugging:
Enable Nova’s API debugging in workbench/config/nova.php:
'debug' => env('NOVA_DEBUG', true),
Environment Variables:
Use .env.workbench to override settings (e.g., NOVA_PATH=workbench):
NOVA_PATH=workbench
NOVA_PORT=8001
Custom Commands: Extend the package by publishing its config:
php artisan vendor:publish --provider="Laravel\NovaDevtool\NovaDevtoolServiceProvider"
Modify config/nova-devtool.php to add custom commands.
Testing: Use Pest or PHPUnit with Workbench:
// tests/Feature/Nova/ExampleTest.php
public function test_example()
{
$response = $this->actingAsUser(factory(User::class)->create())
->get('/nova/resources/posts');
$response->assertStatus(200);
}
Performance:
Disable Nova’s asset optimization in workbench/webpack.mix.js for faster development:
mix.disableSuccessNotifications();
Extending the Package:
Override the nova:devtool commands by publishing and modifying:
php artisan vendor:publish --tag="nova-devtool-commands"
Edit app/Console/Commands/NovaDevtoolSetupCommand.php.
How can I help you explore Laravel packages today?