opscale-co/nova-package-tools
Composer 安装命令:
composer require opscale-co/nova-package-tools
包简介
Tools for creating Nova packages
README 文档
README
At Opscale, we’re passionate about contributing to the open-source community by providing solutions that help businesses scale efficiently. If you’ve found our tools helpful, here are a few ways you can show your support:
⭐ Star this repository to help others discover our work and be part of our growing community. Every star makes a difference!
💬 Share your experience by leaving a review on Trustpilot or sharing your thoughts on social media. Your feedback helps us improve and grow!
📧 Send us feedback on what we can improve at feedback@opscale.co. We value your input to make our tools even better for everyone.
🙏 Get involved by actively contributing to our open-source repositories. Your participation benefits the entire community and helps push the boundaries of what’s possible.
💼 Hire us if you need custom dashboards, admin panels, internal tools or MVPs tailored to your business. With our expertise, we can help you systematize operations or enhance your existing product. Contact us at hire@opscale.co to discuss your project needs.
Thanks for helping Opscale continue to scale! 🚀
Description
This package extends Spatie's Laravel Package Tools to provide Nova-specific functionality for package development. It inherits all the features from the base package while adding support for Nova resources, assets, routes, event listeners and Nova::serving callbacks.
Installation
You can install the package in to a Laravel app that uses Nova via composer:
composer require opscale-co/nova-package-tools
Usage
Getting Started
In your Nova package, you should let your service provider extend Opscale\NovaPackageTools\NovaPackageServiceProvider:
use Opscale\NovaPackageTools\NovaPackageServiceProvider; use Spatie\LaravelPackageTools\Package; class YourNovaPackageServiceProvider extends NovaPackageServiceProvider { public function configurePackage(Package $package): void { $package ->name('your-nova-package') ->hasConfigFile() ->hasViews() ->hasMigration('create_your_package_tables') ->hasCommand(YourPackageCommand::class) // Nova-specific features are now directly available ->hasResource(YourResource::class) ->hasResources([ UserResource::class, PostResource::class, ]) ->hasNovaAssets('your-nova-package', __DIR__.'/../dist') ->hasNovaApiRoute(__DIR__.'/../routes/api.php', 'your-nova-package') ->hasNovaPageRoute(__DIR__.'/../routes/nova.php', '/your-nova-package') ->hasListener(SomeEvent::class, SomeListener::class) ->servingNova(function () { // Register fields, tools, dashboards, etc. }); } }
Nova Resources
The main addition this package provides is the ability to register Nova resources with your package.
Registering a Single Resource
You can register a single Nova resource using the hasResource method:
use App\Nova\User; $package ->name('your-nova-package') ->hasResource(User::class);
Registering Multiple Resources
If your package provides multiple Nova resources, you can register them all at once using hasResources:
use App\Nova\User; use App\Nova\Post; use App\Nova\Comment; $package ->name('your-nova-package') ->hasResources([ User::class, Post::class, Comment::class, ]);
You can also pass multiple resources as separate arguments:
$package ->name('your-nova-package') ->hasResources(User::class, Post::class, Comment::class);
Nova Assets
Register the JavaScript and CSS assets that ship with your Nova tool or field. Assets are published automatically and registered with Nova::script() / Nova::style() inside Nova::serving().
$package ->name('your-nova-package') // Register a single script or style: ->hasNovaScript('your-nova-package', __DIR__.'/../dist/js/tool.js') ->hasNovaStyle('your-nova-package', __DIR__.'/../dist/css/tool.css');
For the typical Nova layout (a dist/ directory containing js/ and css/ folders), use hasNovaAssets() to register both at once:
$package ->name('your-nova-package') // For a Nova tool (dist/js/tool.js + dist/css/tool.css): ->hasNovaAssets('your-nova-package', __DIR__.'/../dist', 'tool'); $package ->name('your-nova-field') // For a Nova field (dist/js/field.js + dist/css/field.css): ->hasNovaAssets('your-nova-field', __DIR__.'/../dist', 'field');
Nova Routes
Register route files that should be loaded with Nova's middleware stack.
Use hasNovaApiRoute() for XHR endpoints called from your Nova tool's Vue components — these are mounted under nova-vendor/{prefix}:
$package ->name('your-nova-package') ->hasNovaApiRoute(__DIR__.'/../routes/api.php', 'your-nova-package');
Use hasNovaPageRoute() for full Nova pages that should render with the standard Nova layout:
$package ->name('your-nova-package') ->hasNovaPageRoute(__DIR__.'/../routes/nova.php', '/your-nova-package');
Both methods accept an optional middleware list as the third argument. When omitted, sensible Nova defaults are applied (['nova', Authorize::class] for API routes and ['nova', Authenticate::class, Authorize::class] for page routes).
$package ->hasNovaApiRoute( __DIR__.'/../routes/api.php', 'your-nova-package', ['nova', Authorize::class, 'custom-middleware'] );
Event Listeners
Register event listeners for your package without having to wire them up manually in a service provider.
use App\Events\OrderShipped; use App\Listeners\SendShipmentNotification; $package ->name('your-nova-package') // Register a single event listener: ->hasListener(OrderShipped::class, SendShipmentNotification::class);
Listeners may be class names, [Class::class, 'method'] arrays, or closures. You can also register multiple listeners at once:
$package ->name('your-nova-package') ->hasListeners([ OrderShipped::class => SendShipmentNotification::class, OrderCancelled::class => [NotifyTeam::class, 'handle'], ]);
Serving Callbacks
Register callbacks that should run inside Nova::serving(). This is the right place to register fields, tools, dashboards, or any other Nova-aware code that needs Nova to be booted first.
use Laravel\Nova\Nova; $package ->name('your-nova-package') ->servingNova(function () { Nova::tools([ new YourPackageTool(), ]); });
You can call servingNova() multiple times to register additional callbacks.
Testing
npm run test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email development@opscale.co instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
opscale-co/nova-package-tools 适用场景与选型建议
opscale-co/nova-package-tools 是一款 基于 Shell 开发的 Composer 扩展包,目前已累计 1.01k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 09 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「opscale」 「nova-package-tools」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 opscale-co/nova-package-tools 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 opscale-co/nova-package-tools 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 opscale-co/nova-package-tools 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Config-based rendering for Nova resources
Add webhooks support triggered by your resource CRUD operations.
Show Nova actions directly in the toolbar
Secure your Nova resources with roles and permissions
Add default secured CRUD API endpoints for your Nova resources.
Capture and process emails in your Nova app
统计信息
- 总下载量: 1.01k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 12
- 依赖项目数: 10
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-09-19