- What is zepfietje/laravel-nova-stubs and why would I use it?
- It is a Composer package that ships clean copies of the stub templates Laravel Nova uses when it generates classes such as resources, actions, filters, lenses and tools. Publishing those stubs into your application lets you edit the templates so every newly generated Nova class follows your own conventions, base classes, namespaces, traits and docblocks. Instead of hand-editing files after each artisan command, you change the template once and all future generated code inherits it.
- How do I install zepfietje/laravel-nova-stubs with Composer?
- Install it with Composer, for example: composer require zepfietje/laravel-nova-stubs. Because the stubs are only needed while generating classes, many teams add it as a dev dependency with the --dev flag so it stays out of production installs. Check the repository README for the recommended flag and any version constraint guidance before committing to a workflow.
- How do I publish the Nova stubs into my Laravel project?
- Publishing is done with Laravel's vendor:publish command, either by selecting the package's service provider or by using the publish tag documented in the README. Run php artisan vendor:publish and pick the entry provided by this package, or pass the tag explicitly if the README lists one. The command output shows exactly which files were written and where, which is the quickest way to confirm the destination directory.
- Where do the published stub files need to live for Laravel Nova to use them?
- Nova reads custom stub templates from a dedicated stubs directory in your project rather than from the vendor folder, so the published files must end up in the location Nova checks. The publish command places them in that directory automatically, and the console output confirms the path. If you move or rename the files afterwards, Nova will silently fall back to its built-in stubs, so keep the published structure intact.
- Does zepfietje/laravel-nova-stubs support PHP 8 and which Laravel and Nova versions work with it?
- Version 2.1.0 added PHP 8 support, which makes the package viable for Laravel 9 and 10 projects that require PHP 8.0 or newer. There is no published compatibility matrix covering every PHP 8 minor version and Laravel pairing, so verify the PHP and framework constraints in the package's composer.json before adopting it. If you need a formal guarantee, test against your exact PHP and Laravel versions in a staging branch, and consider asking the maintainer which combinations are officially supported.
- Can I customize only some stubs and keep Nova's defaults for the rest?
- Yes. After publishing, you can edit, rename or delete individual stub files, and Nova will use its own built-in template for any stub that is not present in your overrides directory. This makes a gradual approach practical: start with the resource stub, for example, and add action, filter, lens or tool stubs later as your conventions settle. Keep track of what you have overridden so future upgrades are easy to review.
- Will customizing the stubs break already generated Nova classes?
- No. Editing a stub only affects classes you generate after the change, because existing PHP files on disk are never rewritten by the templates. If you want the new conventions applied to old classes, regenerate or refactor them manually. It is also worth diffing any existing generated classes against a freshly generated one before regenerating, so you do not accidentally drop custom logic.
- Does this package affect production performance or runtime behaviour?
- The stubs are only read while an artisan generator is producing a class, so there is no runtime overhead in your application. That is why installing it as a dev dependency is usually fine for teams that generate Nova classes locally or in build pipelines. If your deployment process runs Nova generators on the server, install it as a normal dependency instead so the stubs are available there.
- How do I test that my customized stubs generate valid Nova classes?
- Generate a sample resource, action, filter, lens and tool in a throwaway branch, then run PHP linting, Laravel Pint and static analysis such as PHPStan or Larastan over the output. Add the generated classes to your test suite briefly to confirm they boot and register with Nova's component discovery. This catches missing imports, wrong namespaces or incorrect base classes before the stubs reach the rest of the team.
- Is the package actively maintained, and what are the alternatives?
- The 2.1.0 release adding PHP 8 support is a meaningful maintenance signal, but no prior technical assessment exists for this package, so check the repository's commit history and issue activity before relying on it long term. The main alternative is copying Nova's own stub files into your project manually, or overriding just one or two templates by hand. This package mainly saves you the effort of locating and publishing those files and keeping them in a clean, reviewable state.