Have you ever enjoyed the assistance of artisan commands? This package brings more of it :)
You can now generate PHP classes and traits using artisan make:class
, make:interface
, make:trait
or make:abstract-class
console commands.
composer require stephenjude/extended-artisan-commands --dev
You're all set. Run php artisan from the console, and you'll see the new commands in the make:* namespace section.
- make:interface
- make:class
- make:abstract-class
- make:trait
- make:enum
Here's a few other examples of commands that you might write:
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 This will overide the existing file, if it exist
--interface
OR-i
This will generate an interface for the generated class.--trait
OR-t
This will generate a trait for the generated class.--abstract
OR-c
This will generate an abstract class for the generated class.--all
OR-a
This will generate an interface, a trait and an abstract class for the generated class.
This will generate an interface for this class.
php artisan make:class Services/EmailForwarderService --interface
This will generate a trait for this class.
php artisan make:class Services/EmailForwarderService --trait
- All interfaces are generated under the
App/Contracts
namespace. - All traits are generated under the
App/Traits
namespace. - All enums are generated under the
App/Enums
namespace. - Classes and abstract classes are generated under the
App
namespace.
Default namespaces can be configured inside the package config file.
You can configure default namespace by publishing the package config file:
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
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email stephenjudesuccess@gmail.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
This package was generated using the Laravel Package Boilerplate.