next-tecnology/nova-custom-errors
Composer 安装命令:
composer require next-tecnology/nova-custom-errors
包简介
Custom error views for Nova
README 文档
README
Custom error pages for Laravel Nova, provided as a small middleware package.
- Package:
next-tecnology/nova-custom-errors - PHP: ^8.2 | ^8.3 | ^8.4
- Nova: ^4.0 | ^5.0
1) Install
composer require next-tecnology/nova-custom-errors
The service provider is auto-discovered via Composer; no manual registration is needed.
2) Add the middleware to Nova
Edit config/nova.php and add the middleware to Nova's middleware stack. Place it after the standard Nova middleware so it can intercept responses and render the appropriate error views.
// config/nova.php return [ // ... 'middleware' => [ 'web', ..... \NextTecnology\NovaCustomErrors\Http\Middleware\HandleNovaErrors::class, ..... ], // ... ];
That’s it. The middleware will check the response status code and, if it is greater than 400, attempt to render a matching view from this package.
3) Customizing the error views (optional)
By default, the package ships with views that are used immediately without any publishing. If you want to customize them, publish the views to your application and edit them as needed:
php artisan vendor:publish \ --provider="NextTecnology\\NovaCustomErrors\\NovaCustomErrorsServiceProvider" \ --tag="nova-custom-errors-views"
This will copy the views to:
resources/views/vendor/nova-custom-errors/
Available default views in the package:
401.blade.php402.blade.php403.blade.php404.blade.php419.blade.php429.blade.php500.blade.php503.blade.php
The middleware looks up views by status code using the namespace nova-custom-errors::. For example, a 404 response will try to render nova-custom-errors::404 (or your published override at resources/views/vendor/nova-custom-errors/404.blade.php).
How it works
The middleware HandleNovaErrors inspects the response returned by Nova and, for status codes > 400, tries to render a view named after that status code:
$view = 'nova-custom-errors::' . $response->getStatusCode(); if (view()->exists($view)) { return response()->view($view); }
If no matching view exists, the original response is returned unchanged.
Verifying
- Trigger a known error within Nova (e.g., visit a non-existent Nova resource) and you should see the corresponding custom error page.
- If you customized views, ensure your edited versions appear under
resources/views/vendor/nova-custom-errors/.
Troubleshooting
- "Class not found" for the middleware: run
composer dump-autoloadand ensure the fully-qualified class name is correct:\\NextTecnology\\NovaCustomErrors\\Http\\Middleware\\HandleNovaErrors::class. - View not found: ensure the view exists in the package (it does by default), or, if you published views, confirm they are under
resources/views/vendor/nova-custom-errors/with the correct filename (e.g.,404.blade.php). - Config cache: after changing
config/nova.php, runphp artisan config:clear.
License
MIT
Note about assets in the minimal layout
The bundled minimal layout view (resources/views/vendor/nova-custom-errors/minimal.blade.php after publishing, or the package view resources/views/minimal.blade.php) includes this line:
@vite(['resources/css/app.css', 'resources/js/app.js'])
This expects Laravel Vite to build your assets into public/build (the default). If those files are not available in your project, you have two options:
- Provide the assets via Vite (recommended)
- Install dependencies and build once for production:
npm install npm run build
This will produce thepublic/builddirectory and the@vitedirective will work. - Or run the Vite dev server during local development:
npm run dev
Ensure your app is configured to connect to the Vite dev server as usual for your Laravel version.
- Customize the layout to fit your asset pipeline
- Publish the views if you haven’t already:
php artisan vendor:publish \ --provider="NextTecnology\\NovaCustomErrors\\NovaCustomErrorsServiceProvider" \ --tag="nova-custom-errors-views"
- Then edit
resources/views/vendor/nova-custom-errors/minimal.blade.phpand either remove the@vite(...)line or replace it with whatever your project uses (CDN, compiled static files, Mix, etc.). For example:<!-- Replace Vite with direct files or CDN as needed --> <link rel="stylesheet" href="/css/app.css"> <script src="/js/app.js" defer></script>
If your project doesn’t need any custom CSS/JS for these error pages, you can safely remove the @vite([...]) line.
next-tecnology/nova-custom-errors 适用场景与选型建议
next-tecnology/nova-custom-errors 是一款 基于 Blade 开发的 Composer 扩展包,目前已累计 88 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 11 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「errors」 「nova」 「laravel」 「custom-errors」 「error-pages」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 next-tecnology/nova-custom-errors 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 next-tecnology/nova-custom-errors 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 next-tecnology/nova-custom-errors 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Laravel Nova card that shows you your system information.
A Laravel Nova card.
A Laravel Nova package for publishable fields
A Laravel Nova package for translatable fields
Bootstraps errors and handles them via reporters and renderers
Asynchronous Sentry for Symfony - Fire and forget
统计信息
- 总下载量: 88
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-11-20