├── .styleci.yml ├── src ├── stubs │ ├── enum.stub │ ├── trait.stub │ ├── interface.stub │ ├── abstract-class.stub │ └── class.stub ├── Concerns │ ├── WithTrait.php │ ├── WithInterface.php │ ├── WithAbstractClass.php │ └── WithStubCleaner.php ├── ExtendedArtisanCommandsServiceProvider.php └── Commands │ ├── EnumMakeCommand.php │ ├── TraitMakeCommand.php │ ├── InterfaceMakeCommand.php │ ├── AbstractClassMakeCommand.php │ └── ClassMakeCommand.php ├── CHANGELOG.md ├── LICENSE.md ├── composer.json ├── config └── config.php ├── CONTRIBUTING.md └── README.md /.styleci.yml: -------------------------------------------------------------------------------- 1 | preset: laravel 2 | 3 | disabled: 4 | - single_class_element_per_statement 5 | -------------------------------------------------------------------------------- /src/stubs/enum.stub: -------------------------------------------------------------------------------- 1 | argument('name'))); 17 | 18 | $this->call('make:trait', [ 19 | 'name' => "{$trait}", 20 | ]); 21 | } 22 | 23 | /** 24 | * Replace the trait name for the given stub. 25 | * 26 | * @param string $stub 27 | */ 28 | protected function replaceTraitStubs($stub): string 29 | { 30 | $namespace = $this->getTraitNamespace($this->enumName); 31 | 32 | $alias = $this->enumName.'Trait'; 33 | 34 | $useTrait = "$namespace as $alias"; 35 | 36 | $stub = str_replace('DummyTraitNamespace', $useTrait, $stub); 37 | 38 | $stub = str_replace('DummyTrait', $alias, $stub); 39 | 40 | return $stub; 41 | } 42 | 43 | /** 44 | * Parse the trait name and format according to trait root namespace. 45 | * 46 | * @param string $name 47 | */ 48 | protected function getTraitNamespace($name): string 49 | { 50 | $namespace = $this->rootNamespace().config('extended-artisan-commands.trait_namespace')."\\$name"; 51 | 52 | return str_replace('\\\\', '\\', $namespace); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/ExtendedArtisanCommandsServiceProvider.php: -------------------------------------------------------------------------------- 1 | app->runningInConsole()) { 19 | $this->publishes([ 20 | __DIR__.'/../config/config.php' => config_path('extended-artisan-commands.php'), 21 | ], 'config'); 22 | 23 | // Registering package commands. 24 | $this->commands([ 25 | \Stephenjude\ExtendedArtisanCommands\Commands\ClassMakeCommand::class, 26 | \Stephenjude\ExtendedArtisanCommands\Commands\AbstractClassMakeCommand::class, 27 | \Stephenjude\ExtendedArtisanCommands\Commands\InterfaceMakeCommand::class, 28 | \Stephenjude\ExtendedArtisanCommands\Commands\TraitMakeCommand::class, 29 | \Stephenjude\ExtendedArtisanCommands\Commands\EnumMakeCommand::class, 30 | ]); 31 | } 32 | } 33 | 34 | /** 35 | * Register the application services. 36 | */ 37 | public function register() 38 | { 39 | // Automatically apply the package configuration 40 | $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'extended-artisan-commands'); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/Concerns/WithInterface.php: -------------------------------------------------------------------------------- 1 | argument('name'))); 24 | 25 | $this->call('make:interface', [ 26 | 'name' => "{$interface}", 27 | ]); 28 | } 29 | 30 | /** 31 | * Replace the interface name for the given stub. 32 | * 33 | * @param string $stub 34 | */ 35 | protected function replaceInterfaceStubs($stub): string 36 | { 37 | $namespace = $this->getInterfaceNamespace($this->enumName); 38 | 39 | $alias = $this->enumName.$this->suffix; 40 | 41 | $stub = str_replace('DummyInterfaceNamespace', "$namespace as $alias", $stub); 42 | 43 | $stub = str_replace('DummyInterface', $alias, $stub); 44 | 45 | return $stub; 46 | } 47 | 48 | /** 49 | * Parse the interface name and format according to interface root namespace. 50 | * 51 | * @param string $name 52 | */ 53 | protected function getInterfaceNamespace($name): string 54 | { 55 | $namespace = $this->rootNamespace().config('extended-artisan-commands.interface_namespace')."\\$name"; 56 | 57 | return str_replace('\\\\', '\\', $namespace); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "stephenjude/extended-artisan-commands", 3 | "description": "Generate plain PHP files using artisan console commands.", 4 | "keywords": [ 5 | "stephenjude", 6 | "extended-artisan-commands" 7 | ], 8 | "homepage": "https://github.com/stephenjude/extended-artisan-commands", 9 | "license": "MIT", 10 | "type": "library", 11 | "authors": [ 12 | { 13 | "name": "Stephen Jude", 14 | "email": "stephenjudesuccess@gmail.com", 15 | "role": "Developer" 16 | } 17 | ], 18 | "require": { 19 | "php": "^8.0", 20 | "illuminate/support": "^8.0|^9.0|^10.0" 21 | }, 22 | "require-dev": { 23 | "orchestra/testbench": "^6.0|^7.0|^8.0", 24 | "phpunit/phpunit": "^9.5" 25 | }, 26 | "autoload": { 27 | "psr-4": { 28 | "Stephenjude\\ExtendedArtisanCommands\\": "src" 29 | } 30 | }, 31 | "autoload-dev": { 32 | "psr-4": { 33 | "Stephenjude\\ExtendedArtisanCommands\\Tests\\": "tests" 34 | } 35 | }, 36 | "scripts": { 37 | "test": "vendor/bin/phpunit", 38 | "test-coverage": "vendor/bin/phpunit --coverage-html coverage" 39 | 40 | }, 41 | "config": { 42 | "sort-packages": true 43 | }, 44 | "extra": { 45 | "laravel": { 46 | "providers": [ 47 | "Stephenjude\\ExtendedArtisanCommands\\ExtendedArtisanCommandsServiceProvider" 48 | ], 49 | "aliases": { 50 | "ExtendedArtisanCommands": "Stephenjude\\ExtendedArtisanCommands\\ExtendedArtisanCommandsFacade" 51 | } 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/Concerns/WithAbstractClass.php: -------------------------------------------------------------------------------- 1 | argument('name'); 25 | 26 | $name = $this->qualifyClass($className); 27 | 28 | $baseName = class_basename($className); 29 | 30 | $alias = $this->classPrefix.$baseName; 31 | 32 | $abstractClass = Str::studly(str_replace($baseName, $alias, (string) $name)); 33 | 34 | $this->call('make:abstract-class', [ 35 | 'name' => "{$abstractClass}", 36 | ]); 37 | } 38 | 39 | /** 40 | * Replace the abstract class name for the given stub. 41 | * 42 | * @param string $stub 43 | */ 44 | protected function replaceAbstractClassStubs($stub): string 45 | { 46 | $alias = $this->classPrefix.$this->enumName; 47 | 48 | $namespace = $this->getAbstractClassNamespace($alias); 49 | 50 | $stub = str_replace('DummyAbstractClassNamespace', $namespace, $stub); 51 | 52 | $stub = str_replace('DummyAbstractClass', $alias, $stub); 53 | 54 | return $stub; 55 | } 56 | 57 | /** 58 | * Parse the abstract class name and format according to abstract class root namespace. 59 | * 60 | * @param string $name 61 | */ 62 | protected function getAbstractClassNamespace($name): string 63 | { 64 | $namespace = $this->rootNamespace().config('extended-artisan-commands.abstract_namespace')."\\$name"; 65 | 66 | return str_replace('\\\\', '\\', $namespace); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/Concerns/WithStubCleaner.php: -------------------------------------------------------------------------------- 1 | option('all')) { 10 | return $stub; 11 | } 12 | 13 | $stub = $this->cleanTraitStub($stub); 14 | $stub = $this->cleanInterfaceStub($stub); 15 | $stub = $this->cleanAbstractClassStub($stub); 16 | 17 | $stub = preg_replace('/\n\n\n/', PHP_EOL.PHP_EOL, (string) $stub); 18 | $stub = preg_replace('/\n\n\n\n/', PHP_EOL, $stub); 19 | 20 | return $stub; 21 | } 22 | 23 | public function cleanTraitStub($stub): string 24 | { 25 | if (! $this->option('trait')) { 26 | $stub = str_replace('use DummyTraitNamespace;', '', (string) $stub); 27 | $stub = str_replace(' use DummyTrait;', '', $stub); 28 | } 29 | 30 | return $stub; 31 | } 32 | 33 | public function cleanEnumStub($stub): string 34 | { 35 | if (! $this->option('enum')) { 36 | $stub = str_replace('use DummyEnumNamespace;', '', (string) $stub); 37 | $stub = str_replace(' use DummyEnum;', '', $stub); 38 | } 39 | 40 | return $stub; 41 | } 42 | 43 | public function cleanInterfaceStub($stub): string 44 | { 45 | if (! $this->option('interface')) { 46 | $stub = str_replace('use DummyInterfaceNamespace;', '', (string) $stub); 47 | $stub = str_replace('implements DummyInterface', '', $stub); 48 | } 49 | 50 | return $stub; 51 | } 52 | 53 | public function cleanAbstractClassStub($stub): string 54 | { 55 | if (! $this->option('abstract')) { 56 | $stub = str_replace('use DummyAbstractClassNamespace;', '', (string) $stub); 57 | $stub = str_replace('extends DummyAbstractClass ', '', $stub); 58 | } 59 | 60 | return $stub; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /config/config.php: -------------------------------------------------------------------------------- 1 | '', 15 | 16 | /* 17 | |-------------------------------------------------------------------------- 18 | | Default Abstract Class Namespace 19 | |-------------------------------------------------------------------------- 20 | | 21 | | Here you can configure the default namespace for 22 | | the make:abstract-class command. 23 | | 24 | */ 25 | 26 | 'abstract_class_namespace' => '', 27 | 28 | /* 29 | |-------------------------------------------------------------------------- 30 | | Default Interface Namespace 31 | |-------------------------------------------------------------------------- 32 | | 33 | | Here you can configure the default namespace for 34 | | the make:interface command. 35 | | 36 | */ 37 | 38 | 'interface_namespace' => '\Contracts', 39 | 40 | /* 41 | |-------------------------------------------------------------------------- 42 | | Default Trait Namespace 43 | |-------------------------------------------------------------------------- 44 | | 45 | | Here you can configure the default namespace for 46 | | the make:trait command. 47 | | 48 | */ 49 | 50 | 'trait_namespace' => '\Traits', 51 | 52 | /* 53 | |-------------------------------------------------------------------------- 54 | | Default Enum Namespace 55 | |-------------------------------------------------------------------------- 56 | | 57 | | Here you can configure the default namespace for 58 | | the make:enum command. 59 | | 60 | */ 61 | 62 | 'enum_namespace' => '\Enums', 63 | ]; 64 | -------------------------------------------------------------------------------- /src/Commands/EnumMakeCommand.php: -------------------------------------------------------------------------------- 1 | argument('name')); 44 | 45 | return str_replace('DummyEnum', $enumName, $stub); 46 | } 47 | 48 | /** 49 | * Get the stub file for the generator. 50 | * 51 | * @return string 52 | */ 53 | protected function getStub() 54 | { 55 | return __DIR__.'/../stubs/enum.stub'; 56 | } 57 | 58 | /** 59 | * Get the default namespace for the class. 60 | * 61 | * @param string $rootNamespace 62 | * @return string 63 | */ 64 | protected function getDefaultNamespace($rootNamespace) 65 | { 66 | return $rootNamespace.config('extended-artisan-commands.enum_namespace'); 67 | } 68 | 69 | /** 70 | * Get the console command arguments. 71 | * 72 | * @return array 73 | */ 74 | protected function getArguments() 75 | { 76 | return [ 77 | ['name', InputArgument::REQUIRED, 'The name of the enum.'], 78 | ]; 79 | } 80 | 81 | /** 82 | * Get the console command options. 83 | */ 84 | protected function getOptions(): array 85 | { 86 | return [ 87 | ['force', null, InputOption::VALUE_NONE, 'Create the enum even if the enum already exists'], 88 | ]; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/Commands/TraitMakeCommand.php: -------------------------------------------------------------------------------- 1 | argument('name')); 44 | 45 | return str_replace('DummyTrait', $traitName, $stub); 46 | } 47 | 48 | /** 49 | * Get the stub file for the generator. 50 | * 51 | * @return string 52 | */ 53 | protected function getStub() 54 | { 55 | return __DIR__.'/../stubs/trait.stub'; 56 | } 57 | 58 | /** 59 | * Get the default namespace for the class. 60 | * 61 | * @param string $rootNamespace 62 | * @return string 63 | */ 64 | protected function getDefaultNamespace($rootNamespace) 65 | { 66 | return $rootNamespace.config('extended-artisan-commands.trait_namespace'); 67 | } 68 | 69 | /** 70 | * Get the console command arguments. 71 | * 72 | * @return array 73 | */ 74 | protected function getArguments() 75 | { 76 | return [ 77 | ['name', InputArgument::REQUIRED, 'The name of the trait.'], 78 | ]; 79 | } 80 | 81 | /** 82 | * Get the console command options. 83 | * 84 | * @return array 85 | */ 86 | protected function getOptions() 87 | { 88 | return [ 89 | ['force', null, InputOption::VALUE_NONE, 'Create the trait even if the trait already exists'], 90 | ]; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/Commands/InterfaceMakeCommand.php: -------------------------------------------------------------------------------- 1 | argument('name')); 44 | 45 | return str_replace('DummyInterface', $className, $stub); 46 | } 47 | 48 | /** 49 | * Get the stub file for the generator. 50 | * 51 | * @return string 52 | */ 53 | protected function getStub() 54 | { 55 | return __DIR__.'/../stubs/interface.stub'; 56 | } 57 | 58 | /** 59 | * Get the default namespace for the class. 60 | * 61 | * @param string $rootNamespace 62 | * @return string 63 | */ 64 | protected function getDefaultNamespace($rootNamespace) 65 | { 66 | return $rootNamespace.config('extended-artisan-commands.interface_namespace'); 67 | } 68 | 69 | /** 70 | * Get the console command arguments. 71 | * 72 | * @return array 73 | */ 74 | protected function getArguments() 75 | { 76 | return [ 77 | ['name', InputArgument::REQUIRED, 'The name of the interface.'], 78 | ]; 79 | } 80 | 81 | /** 82 | * Get the console command options. 83 | * 84 | * @return array 85 | */ 86 | protected function getOptions() 87 | { 88 | return [ 89 | ['force', null, InputOption::VALUE_NONE, 'Create the interface even if it already exists'], 90 | ]; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/Commands/AbstractClassMakeCommand.php: -------------------------------------------------------------------------------- 1 | argument('name')); 44 | 45 | return str_replace('DummyAbstractClass', $className, $stub); 46 | } 47 | 48 | /** 49 | * Get the stub file for the generator. 50 | * 51 | * @return string 52 | */ 53 | protected function getStub() 54 | { 55 | return __DIR__.'/../stubs/abstract-class.stub'; 56 | } 57 | 58 | /** 59 | * Get the default namespace for the class. 60 | * 61 | * @param string $rootNamespace 62 | * @return string 63 | */ 64 | protected function getDefaultNamespace($rootNamespace) 65 | { 66 | return $rootNamespace.config('extended-artisan-commands.abstract_class_namespace'); 67 | } 68 | 69 | /** 70 | * Get the console command arguments. 71 | * 72 | * @return array 73 | */ 74 | protected function getArguments() 75 | { 76 | return [ 77 | ['name', InputArgument::REQUIRED, 'The name of the abstract class.'], 78 | ]; 79 | } 80 | 81 | /** 82 | * Get the console command options. 83 | * 84 | * @return array 85 | */ 86 | protected function getOptions() 87 | { 88 | return [ 89 | ['force', null, InputOption::VALUE_NONE, 'Create the abstract class even if it already exists'], 90 | ]; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Contributions are **welcome** and will be fully **credited**. 4 | 5 | Please read and understand the contribution guide before creating an issue or pull request. 6 | 7 | ## Etiquette 8 | 9 | This project is open source, and as such, the maintainers give their free time to build and maintain the source code 10 | held within. They make the code freely available in the hope that it will be of use to other developers. It would be 11 | extremely unfair for them to suffer abuse or anger for their hard work. 12 | 13 | Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the 14 | world that developers are civilized and selfless people. 15 | 16 | It's the duty of the maintainer to ensure that all submissions to the project are of sufficient 17 | quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used. 18 | 19 | ## Viability 20 | 21 | When requesting or submitting new features, first consider whether it might be useful to others. Open 22 | source projects are used by many developers, who may have entirely different needs to your own. Think about 23 | whether or not your feature is likely to be used by other users of the project. 24 | 25 | ## Procedure 26 | 27 | Before filing an issue: 28 | 29 | - Attempt to replicate the problem, to ensure that it wasn't a coincidental incident. 30 | - Check to make sure your feature suggestion isn't already present within the project. 31 | - Check the pull requests tab to ensure that the bug doesn't have a fix in progress. 32 | - Check the pull requests tab to ensure that the feature isn't already in progress. 33 | 34 | Before submitting a pull request: 35 | 36 | - Check the codebase to ensure that your feature doesn't already exist. 37 | - Check the pull requests to ensure that another person hasn't already submitted the feature or fix. 38 | 39 | ## Requirements 40 | 41 | If the project maintainer has any additional requirements, you will find them listed here. 42 | 43 | - **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer). 44 | 45 | - **Add tests!** - Your patch won't be accepted if it doesn't have tests. 46 | 47 | - **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. 48 | 49 | - **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option. 50 | 51 | - **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. 52 | 53 | - **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. 54 | 55 | **Happy coding**! 56 | -------------------------------------------------------------------------------- /src/Commands/ClassMakeCommand.php: -------------------------------------------------------------------------------- 1 | setUp(); 53 | 54 | if (parent::handle() === false && ! $this->option('force')) { 55 | return false; 56 | } 57 | 58 | if ($this->option('interface')) { 59 | $this->createInterface(); 60 | } 61 | 62 | if ($this->option('abstract')) { 63 | $this->createAbstractClass(); 64 | } 65 | 66 | if ($this->option('trait')) { 67 | $this->createTrait(); 68 | } 69 | } 70 | 71 | public function setUp(): void 72 | { 73 | $this->className = class_basename($this->argument('name')); 74 | 75 | if ($this->option('all')) { 76 | $this->input->setOption('interface', true); 77 | $this->input->setOption('abstract', true); 78 | $this->input->setOption('trait', true); 79 | } 80 | } 81 | 82 | /** 83 | * Replace the class name for the given stub. 84 | * 85 | * @param string $stub 86 | * @param string $name 87 | * @return string 88 | */ 89 | protected function replaceClass($stub, $name) 90 | { 91 | $stub = parent::replaceClass($stub, $name); 92 | 93 | $stub = str_replace('DummyClass', $this->className, $stub); 94 | 95 | if ($this->option('interface')) { 96 | $stub = $this->replaceInterfaceStubs($stub); 97 | } 98 | 99 | if ($this->option('abstract')) { 100 | $stub = $this->replaceAbstractClassStubs($stub); 101 | } 102 | 103 | if ($this->option('trait')) { 104 | $stub = $this->replaceTraitStubs($stub); 105 | } 106 | 107 | $stub = $this->cleanStubs($stub); 108 | 109 | return $stub; 110 | } 111 | 112 | /** 113 | * Get the stub file for the generator. 114 | * 115 | * @return string 116 | */ 117 | protected function getStub() 118 | { 119 | return __DIR__.'/../stubs/class.stub'; 120 | } 121 | 122 | /** 123 | * Get the default namespace for the class. 124 | * 125 | * @param string $rootNamespace 126 | * @return string 127 | */ 128 | protected function getDefaultNamespace($rootNamespace) 129 | { 130 | return $rootNamespace.config('extended-artisan-commands.class_namespace'); 131 | } 132 | 133 | /** 134 | * Get the console command arguments. 135 | * 136 | * @return array 137 | */ 138 | protected function getArguments() 139 | { 140 | return [ 141 | ['name', InputArgument::REQUIRED, 'The name of the class.'], 142 | ]; 143 | } 144 | 145 | /** 146 | * Get the console command options. 147 | * 148 | * @return array 149 | */ 150 | protected function getOptions() 151 | { 152 | return [ 153 | ['all', 'a', InputOption::VALUE_NONE, 'Generate an interface, an abstract class and a trait for the class'], 154 | ['force', null, InputOption::VALUE_NONE, 'Create the class even if the class already exists'], 155 | ['interface', 'i', InputOption::VALUE_NONE, 'Create a new interface for the class'], 156 | ['abstract', 'c', InputOption::VALUE_NONE, 'Create a new abstract class for the class'], 157 | ['trait', 't', InputOption::VALUE_NONE, 'Create a new trait for the class'], 158 | ]; 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Extended Artisan Commands 2 | 3 | [![Latest Version on Packagist](https://img.shields.io/packagist/v/stephenjude/extended-artisan-commands.svg?style=flat-square)](https://packagist.org/packages/stephenjude/extended-artisan-commands) 4 | [![Build Status](https://img.shields.io/travis/stephenjude/extended-artisan-commands/master.svg?style=flat-square)](https://travis-ci.org/stephenjude/extended-artisan-commands) 5 | [![Total Downloads](https://img.shields.io/packagist/dt/stephenjude/extended-artisan-commands.svg?style=flat-square)](https://packagist.org/packages/stephenjude/extended-artisan-commands) 6 | 7 | Have you ever enjoyed the assistance of artisan commands? This package brings more of it :) 8 | 9 | You can now generate PHP classes and traits using artisan `make:class`, `make:interface`, `make:trait` or `make:abstract-class` console commands. 10 | 11 | ## Installation 12 | ### Step 1: Install Through Composer 13 | ```bash 14 | composer require stephenjude/extended-artisan-commands --dev 15 | ``` 16 | ### Step 2: Run Artisan! 17 | You're all set. Run php artisan from the console, and you'll see the new commands in the make:* namespace section. 18 | - make:interface 19 | - make:class 20 | - make:abstract-class 21 | - make:trait 22 | - make:enum 23 | 24 | ## Usage 25 | Here's a few other examples of commands that you might write: 26 | 27 | ``` bash 28 | php artisan make:class Services/EmailForwarderService 29 | ``` 30 | ``` bash 31 | php artisan make:abstract-class Services/AbstractEmailForwarder 32 | ``` 33 | ``` bash 34 | php artisan make:interface EmailForwarderContract 35 | ``` 36 | ``` bash 37 | php artisan make:trait FileUpload 38 | ``` 39 | ``` bash 40 | php artisan make:enum Permission 41 | ``` 42 | ### Option for all the commands 43 | --force This will overide the existing file, if it exist 44 | 45 | ### Options for the `make:class` command 46 | - `--interface` OR `-i` This will generate an interface for the generated class. 47 | - `--trait` OR `-t` This will generate a trait for the generated class. 48 | - `--abstract` OR `-c` This will generate an abstract class for the generated class. 49 | - `--all` OR `-a` This will generate an interface, a trait and an abstract class for the generated class. 50 | 51 | #### Example: 52 | This will generate an interface for this class. 53 | ```bash 54 | php artisan make:class Services/EmailForwarderService --interface 55 | ``` 56 | 57 | This will generate a trait for this class. 58 | ```bash 59 | php artisan make:class Services/EmailForwarderService --trait 60 | ``` 61 | 62 | ### Default Namespaces 63 | - All interfaces are generated under the `App/Contracts` namespace. 64 | - All traits are generated under the `App/Traits` namespace. 65 | - All enums are generated under the `App/Enums` namespace. 66 | - Classes and abstract classes are generated under the `App` namespace. 67 | 68 | Default namespaces can be configured inside the package config file. 69 | 70 | ## Configurations 71 | You can configure default namespace by publishing the package config file: 72 | ```bash 73 | php artisan vendor:publish --provider="Stephenjude\ExtendedArtisanCommands\ExtendedArtisanCommandsServiceProvider" --tag="config" 74 | ``` 75 | ### Configuring Default Namespace 76 | ```php 77 | return [ 78 | /* 79 | |-------------------------------------------------------------------------- 80 | | Default Class Namespace 81 | |-------------------------------------------------------------------------- 82 | | 83 | | Here you can configure the default namespace for 84 | | the make:class command. 85 | | 86 | */ 87 | 88 | 'class_namespace' => '', 89 | 90 | 91 | /* 92 | |-------------------------------------------------------------------------- 93 | | Default Abstract Class Namespace 94 | |-------------------------------------------------------------------------- 95 | | 96 | | Here you can configure the default namespace for 97 | | the make:abstract-class command. 98 | | 99 | */ 100 | 101 | 'abstract_class_namespace' => '', 102 | 103 | 104 | /* 105 | |-------------------------------------------------------------------------- 106 | | Default Interface Namespace 107 | |-------------------------------------------------------------------------- 108 | | 109 | | Here you can configure the default namespace for 110 | | the make:interface command. 111 | | 112 | */ 113 | 114 | 'interface_namespace' => '\Contracts', 115 | 116 | 117 | /* 118 | |-------------------------------------------------------------------------- 119 | | Default Trait Namespace 120 | |-------------------------------------------------------------------------- 121 | | 122 | | Here you can configure the default namespace for 123 | | the make:trait command. 124 | | 125 | */ 126 | 127 | 'trait_namespace' => '\Traits', 128 | 129 | /* 130 | |-------------------------------------------------------------------------- 131 | | Default Enum Namespace 132 | |-------------------------------------------------------------------------- 133 | | 134 | | Here you can configure the default namespace for 135 | | the make:enum command. 136 | | 137 | */ 138 | 139 | 'enum_namespace' => '\Enums', 140 | ]; 141 | ``` 142 | 143 | ### Testing 144 | 145 | ``` bash 146 | composer test 147 | ``` 148 | 149 | ### Changelog 150 | 151 | Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently. 152 | 153 | ## Contributing 154 | 155 | Please see [CONTRIBUTING](CONTRIBUTING.md) for details. 156 | 157 | ### Security 158 | 159 | If you discover any security related issues, please email stephenjudesuccess@gmail.com instead of using the issue tracker. 160 | 161 | ## Credits 162 | 163 | - [Stephen Jude](https://github.com/stephenjude) 164 | - [All Contributors](../../contributors) 165 | 166 | ## License 167 | 168 | The MIT License (MIT). Please see [License File](LICENSE.md) for more information. 169 | 170 | ## Laravel Package Boilerplate 171 | 172 | This package was generated using the [Laravel Package Boilerplate](https://laravelpackageboilerplate.com). 173 | --------------------------------------------------------------------------------