silverhand7 / laravel-artisan-maker
一个简单的包,可以帮助您创建服务或动作类的样板。
v3.0.1
2023-12-30 03:18 UTC
Requires
- php: ^8.1
- spatie/laravel-package-tools: ^1.9.2
Requires (Dev)
- orchestra/testbench: ^8.19
README
一个简单的包,可以帮助您使用 artisan 命令创建服务、动作、接口和外观类的样板。
使用示例
php artisan make:action UserStoreAction
php artisan make:service UserService
php artisan make:interface UserServiceInterface
php artisan make:facade UserFacade
安装
composer require silverhand7/laravel-artisan-maker
用法
创建服务类
运行以下命令
php artisan make:service {YourService}
服务将被创建,并可以在 app/Services/{YourService}.php 中找到
例如: php artisan make:service UserService
此外,您还可以创建一个实现接口类的服务
php artisan make:service {YourService} --interface={YourInterface}
或
php artisan make:service {YourService} -i {YourInterface}
创建动作类
运行以下命令
php artisan make:action {YourAction}
动作将被创建,并可以在 app/Actions/{YourAction}.php 中找到
例如: php artisan make:action UserStoreAction
创建接口类
运行以下命令
php artisan make:interface {YourInterface}
接口将被创建,并可以在 app/Contracts/{YourInterface}.php 中找到
例如: php artisan make:interface UserServiceInterface
创建外观类
运行以下命令
php artisan make:facade {YourFacade}
外观将被创建,并可以在 app/Facades/{YourFacade}.php 中找到
例如: php artisan make:facade UserFacade
自定义命名空间和生成文件位置
您可以通过以下命令轻松自定义 Service、Action、Interface 或 Facade 类的位置
php artisan vendor:publish --tag=artisan-maker-config
您可以在 config/artisan-maker.php
中进行自定义,例如
'service_interface' => 'App\MyOwnServices'
'service_directory' => 'app/MyOwnServices'
您下一次生成的服务将位于 app/MyOwnServices
文件夹中,并且服务的命名空间将是 App\MyOwnServices
。