stephenjude / extended-artisan-commands
使用 artisan 控制台命令生成纯 PHP 文件。
3.0.3
2023-06-01 12:38 UTC
Requires
- php: ^8.0
- illuminate/support: ^8.0|^9.0|^10.0
Requires (Dev)
- orchestra/testbench: ^6.0|^7.0|^8.0
- phpunit/phpunit: ^9.5
README
您是否曾经享受过 artisan 命令的协助?这个包带来了更多的帮助 :)
现在,您可以使用 artisan 的 make:class
、make:interface
、make:trait
或 make:abstract-class
控制台命令生成 PHP 类和特性。
安装
步骤 1:通过 Composer 安装
composer require stephenjude/extended-artisan-commands --dev
步骤 2:运行 artisan!
设置完成。在控制台中运行 php artisan,您将在 make:* 命名空间部分看到新命令。
- make:interface
- make:class
- make:abstract-class
- make:trait
- make:enum
使用方法
以下是一些您可能编写的其他命令示例
php artisan make:class Services/EmailForwarderService
php artisan make:abstract-class Services/AbstractEmailForwarder
php artisan make:interface EmailForwarderContract
php artisan make:trait FileUpload
php artisan make:enum Permission
所有命令的选项
--force 这个选项将覆盖现有文件,如果存在的话
make:class
命令的选项
--interface
或-i
这将为生成的类生成一个接口。--trait
或-t
这将为生成的类生成一个特性。--abstract
或-c
这将为生成的类生成一个抽象类。--all
或-a
这将为生成的类生成一个接口、一个特性和一个抽象类。
示例
这将为这个类生成一个接口。
php artisan make:class Services/EmailForwarderService --interface
这将为这个类生成一个特性。
php artisan make:class Services/EmailForwarderService --trait
默认命名空间
- 所有接口都在
App/Contracts
命名空间下生成。 - 所有特性都在
App/Traits
命名空间下生成。 - 所有枚举都在
App/Enums
命名空间下生成。 - 类和抽象类都在
App
命名空间下生成。
默认命名空间可以在包配置文件中配置。
配置
您可以通过发布包配置文件来配置默认命名空间
php artisan vendor:publish --provider="Stephenjude\ExtendedArtisanCommands\ExtendedArtisanCommandsServiceProvider" --tag="config"
配置默认命名空间
return [ /* |-------------------------------------------------------------------------- | Default Class Namespace |-------------------------------------------------------------------------- | | Here you can configure the default namespace for | the make:class command. | */ 'class_namespace' => '', /* |-------------------------------------------------------------------------- | Default Abstract Class Namespace |-------------------------------------------------------------------------- | | Here you can configure the default namespace for | the make:abstract-class command. | */ 'abstract_class_namespace' => '', /* |-------------------------------------------------------------------------- | Default Interface Namespace |-------------------------------------------------------------------------- | | Here you can configure the default namespace for | the make:interface command. | */ 'interface_namespace' => '\Contracts', /* |-------------------------------------------------------------------------- | Default Trait Namespace |-------------------------------------------------------------------------- | | Here you can configure the default namespace for | the make:trait command. | */ 'trait_namespace' => '\Traits', /* |-------------------------------------------------------------------------- | Default Enum Namespace |-------------------------------------------------------------------------- | | Here you can configure the default namespace for | the make:enum command. | */ 'enum_namespace' => '\Enums', ];
测试
composer test
更新日志
请参阅 CHANGELOG 了解最近更改的详细信息。
贡献
请参阅 CONTRIBUTING 了解详细信息。
安全
如果您发现任何与安全相关的问题,请通过电子邮件 stephenjudesuccess@gmail.com 联系,而不是使用问题跟踪器。
鸣谢
许可
MIT 许可证 (MIT)。请参阅 许可文件 了解更多信息。
Laravel 包模板
此包是使用 Laravel 包模板 生成的。