diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..8e5439a --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Andrey Sosnov aka ATehnix + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..5445fa9 --- /dev/null +++ b/README.md @@ -0,0 +1,56 @@ +# Override Laravel stubs +[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) +[![Packagist Version](https://img.shields.io/packagist/v/atehnix/laravel-stubs.svg)](https://packagist.org/packages/atehnix/laravel-stubs) + +The package gives you the opportunity to customize Artisan commands like `artisan make:model`, `artisan make:controller` and other, just as you need. + +Any location of the generated classes and with any content. + +## Installation + +You can get library through [composer](https://getcomposer.org/) + +``` +composer require atehnix/laravel-stubs +``` + +Next up, the service provider +`Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,` + +should be replaced by +`ATehnix\LaravelStubs\Providers\ConsoleSupportServiceProvider::class,` + +```php +// config/app.php + +'providers' => [ + ... + // Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class, + ATehnix\LaravelStubs\Providers\ConsoleSupportServiceProvider::class, + ... +]; +``` + +To publish the config file to app/config/stubs.php run: + +``` +php artisan vendor:publish --provider=ATehnix\LaravelStubs\Providers\ConsoleSupportServiceProvider +``` + +Done! + + +## Usage + +### Publish stub files for edit +``` +php artisan stubs:publish +``` + +The files will be placed in the directory `resources/stubs` (or other directory if you change it in the configuration file). + +Now you can edit any of the stubs and enjoy your customized commands like `artisan make:model`,` artisan make:controller` and others. + + +## License +[MIT](LICENSE) diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..74f3848 --- /dev/null +++ b/composer.json @@ -0,0 +1,22 @@ +{ + "name": "atehnix/laravel-stubs", + "description": "Override default stubs", + "keywords": [ + "laravel", + "stub", + "make", + "generator" + ], + "type": "library", + "license": "MIT", + "authors": [ + { + "name": "Andrey Sosnov", + "email": "atehnix@gmail.com" + } + ], + "require": { + "php": ">=5.6.4", + "laravel/framework": "5.3.*" + } +} diff --git a/publish/config/stubs.php b/publish/config/stubs.php new file mode 100644 index 0000000..69d0f51 --- /dev/null +++ b/publish/config/stubs.php @@ -0,0 +1,33 @@ + base_path('resources/stubs'), + + /* + |-------------------------------------------------------------------------- + | Default namespaces for the classes + |-------------------------------------------------------------------------- + | Root application namespaсe (like "App") should be skipped. + */ + 'namespaces' => [ + 'console' => '\Console\Commands', + 'controller' => '\Http\Controllers', + 'event' => '\Events', + 'job' => '\Jobs', + 'listener' => '\Listeners', + 'mail' => '\Mail', + 'middleware' => '\Http\Middleware', + 'model' => '\Models', + 'notification' => '\Notifications', + 'policy' => '\Policies', + 'provider' => '\Providers', + 'request' => '\Http\Requests', + ], + +]; diff --git a/src/Console/ConsoleMakeCommand.php b/src/Console/ConsoleMakeCommand.php new file mode 100644 index 0000000..44500ab --- /dev/null +++ b/src/Console/ConsoleMakeCommand.php @@ -0,0 +1,38 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace ATehnix\LaravelStubs\Console; + +use Illuminate\Foundation\Console\ConsoleMakeCommand as BaseConsoleMakeCommand; + +class ConsoleMakeCommand extends BaseConsoleMakeCommand +{ + /** + * Get the stub file for the generator. + * + * @return string + */ + protected function getStub() + { + $stub = config('stubs.path').'/console.stub'; + + return file_exists($stub) ? $stub : parent::getStub(); + } + + /** + * Get the default namespace for the class. + * + * @param string $rootNamespace + * @return string + */ + protected function getDefaultNamespace($rootNamespace) + { + return $rootNamespace.config('stubs.namespaces.console'); + } +} diff --git a/src/Console/ControllerMakeCommand.php b/src/Console/ControllerMakeCommand.php new file mode 100644 index 0000000..8f26711 --- /dev/null +++ b/src/Console/ControllerMakeCommand.php @@ -0,0 +1,42 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace ATehnix\LaravelStubs\Console; + +use Illuminate\Routing\Console\ControllerMakeCommand as BaseControllerMakeCommand; + +class ControllerMakeCommand extends BaseControllerMakeCommand +{ + /** + * Get the stub file for the generator. + * + * @return string + */ + protected function getStub() + { + if ($this->option('resource')) { + $stub = config('stubs.path').'/controller.stub'; + } else { + $stub = config('stubs.path').'/controller.plain.stub'; + } + + return file_exists($stub) ? $stub : parent::getStub(); + } + + /** + * Get the default namespace for the class. + * + * @param string $rootNamespace + * @return string + */ + protected function getDefaultNamespace($rootNamespace) + { + return $rootNamespace.config('stubs.namespaces.controller'); + } +} diff --git a/src/Console/EventMakeCommand.php b/src/Console/EventMakeCommand.php new file mode 100644 index 0000000..eaf6110 --- /dev/null +++ b/src/Console/EventMakeCommand.php @@ -0,0 +1,38 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace ATehnix\LaravelStubs\Console; + +use Illuminate\Foundation\Console\EventMakeCommand as BaseEventMakeCommand; + +class EventMakeCommand extends BaseEventMakeCommand +{ + /** + * Get the stub file for the generator. + * + * @return string + */ + protected function getStub() + { + $stub = config('stubs.path').'/event.stub'; + + return file_exists($stub) ? $stub : parent::getStub(); + } + + /** + * Get the default namespace for the class. + * + * @param string $rootNamespace + * @return string + */ + protected function getDefaultNamespace($rootNamespace) + { + return $rootNamespace.config('stubs.namespaces.event'); + } +} diff --git a/src/Console/JobMakeCommand.php b/src/Console/JobMakeCommand.php new file mode 100644 index 0000000..90a22e6 --- /dev/null +++ b/src/Console/JobMakeCommand.php @@ -0,0 +1,42 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace ATehnix\LaravelStubs\Console; + +use Illuminate\Foundation\Console\JobMakeCommand as BaseJobMakeCommand; + +class JobMakeCommand extends BaseJobMakeCommand +{ + /** + * Get the stub file for the generator. + * + * @return string + */ + protected function getStub() + { + if ($this->option('sync')) { + $stub = config('stubs.path').'/job.stub'; + } else { + $stub = config('stubs.path').'/job-queued.stub'; + } + + return file_exists($stub) ? $stub : parent::getStub(); + } + + /** + * Get the default namespace for the class. + * + * @param string $rootNamespace + * @return string + */ + protected function getDefaultNamespace($rootNamespace) + { + return $rootNamespace.config('stubs.namespaces.job'); + } +} diff --git a/src/Console/ListenerMakeCommand.php b/src/Console/ListenerMakeCommand.php new file mode 100644 index 0000000..6857ec7 --- /dev/null +++ b/src/Console/ListenerMakeCommand.php @@ -0,0 +1,66 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace ATehnix\LaravelStubs\Console; + +use Illuminate\Foundation\Console\ListenerMakeCommand as BaseListenerMakeCommand; +use Illuminate\Support\Str; + +class ListenerMakeCommand extends BaseListenerMakeCommand +{ + /** + * Get the stub file for the generator. + * + * @return string + */ + protected function getStub() + { + if ($this->option('queued')) { + $stub = config('stubs.path').'/listener-queued.stub'; + } else { + $stub = config('stubs.path').'/listener.stub'; + } + + return file_exists($stub) ? $stub : parent::getStub(); + } + + /** + * Get the default namespace for the class. + * + * @param string $rootNamespace + * @return string + */ + protected function getDefaultNamespace($rootNamespace) + { + return $rootNamespace.config('stubs.namespaces.listener'); + } + + protected function buildClass($name) + { + $stub = $this->files->get($this->getStub()); + $stub = $this->replaceNamespace($stub, $name)->replaceClass($stub, $name); + $event = $this->getEvent(); + $stub = str_replace('DummyEvent', class_basename($event), $stub); + $stub = str_replace('DummyFullEvent', $event, $stub); + + return $stub; + } + + protected function getEvent() + { + $event = $this->option('event'); + + if (! Str::startsWith($event, $this->laravel->getNamespace()) && ! Str::startsWith($event, 'Illuminate')) { + $eventNamespace = ltrim(config('stubs.namespaces.event'), '\\').'\\'; + $event = $this->laravel->getNamespace().$eventNamespace.$event; + } + + return $event; + } +} diff --git a/src/Console/MailMakeCommand.php b/src/Console/MailMakeCommand.php new file mode 100644 index 0000000..cf48384 --- /dev/null +++ b/src/Console/MailMakeCommand.php @@ -0,0 +1,38 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace ATehnix\LaravelStubs\Console; + +use Illuminate\Foundation\Console\MailMakeCommand as BaseMailMakeCommand; + +class MailMakeCommand extends BaseMailMakeCommand +{ + /** + * Get the stub file for the generator. + * + * @return string + */ + protected function getStub() + { + $stub = config('stubs.path').'/mail.stub'; + + return file_exists($stub) ? $stub : parent::getStub(); + } + + /** + * Get the default namespace for the class. + * + * @param string $rootNamespace + * @return string + */ + protected function getDefaultNamespace($rootNamespace) + { + return $rootNamespace.config('stubs.namespaces.mail'); + } +} diff --git a/src/Console/MiddlewareMakeCommand.php b/src/Console/MiddlewareMakeCommand.php new file mode 100644 index 0000000..bffc827 --- /dev/null +++ b/src/Console/MiddlewareMakeCommand.php @@ -0,0 +1,38 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace ATehnix\LaravelStubs\Console; + +use Illuminate\Routing\Console\MiddlewareMakeCommand as BaseMiddlewareMakeCommand; + +class MiddlewareMakeCommand extends BaseMiddlewareMakeCommand +{ + /** + * Get the stub file for the generator. + * + * @return string + */ + protected function getStub() + { + $stub = config('stubs.path').'/middleware.stub'; + + return file_exists($stub) ? $stub : parent::getStub(); + } + + /** + * Get the default namespace for the class. + * + * @param string $rootNamespace + * @return string + */ + protected function getDefaultNamespace($rootNamespace) + { + return $rootNamespace.config('stubs.namespaces.middleware'); + } +} diff --git a/src/Console/ModelMakeCommand.php b/src/Console/ModelMakeCommand.php new file mode 100644 index 0000000..4127c4e --- /dev/null +++ b/src/Console/ModelMakeCommand.php @@ -0,0 +1,38 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace ATehnix\LaravelStubs\Console; + +use Illuminate\Foundation\Console\ModelMakeCommand as BaseModelMakeCommand; + +class ModelMakeCommand extends BaseModelMakeCommand +{ + /** + * Get the stub file for the generator. + * + * @return string + */ + protected function getStub() + { + $stub = config('stubs.path').'/model.stub'; + + return file_exists($stub) ? $stub : parent::getStub(); + } + + /** + * Get the default namespace for the class. + * + * @param string $rootNamespace + * @return string + */ + protected function getDefaultNamespace($rootNamespace) + { + return $rootNamespace.config('stubs.namespaces.model'); + } +} diff --git a/src/Console/NotificationMakeCommand.php b/src/Console/NotificationMakeCommand.php new file mode 100644 index 0000000..1f882b4 --- /dev/null +++ b/src/Console/NotificationMakeCommand.php @@ -0,0 +1,38 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace ATehnix\LaravelStubs\Console; + +use Illuminate\Foundation\Console\NotificationMakeCommand as BaseNotificationMakeCommand; + +class NotificationMakeCommand extends BaseNotificationMakeCommand +{ + /** + * Get the stub file for the generator. + * + * @return string + */ + protected function getStub() + { + $stub = config('stubs.path').'/notification.stub'; + + return file_exists($stub) ? $stub : parent::getStub(); + } + + /** + * Get the default namespace for the class. + * + * @param string $rootNamespace + * @return string + */ + protected function getDefaultNamespace($rootNamespace) + { + return $rootNamespace.config('stubs.namespaces.notification'); + } +} diff --git a/src/Console/PolicyMakeCommand.php b/src/Console/PolicyMakeCommand.php new file mode 100644 index 0000000..6034ac6 --- /dev/null +++ b/src/Console/PolicyMakeCommand.php @@ -0,0 +1,42 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace ATehnix\LaravelStubs\Console; + +use Illuminate\Foundation\Console\PolicyMakeCommand as BasePolicyMakeCommand; + +class PolicyMakeCommand extends BasePolicyMakeCommand +{ + /** + * Get the stub file for the generator. + * + * @return string + */ + protected function getStub() + { + if ($this->option('model')) { + $stub = config('stubs.path').'/policy.stub'; + } else { + $stub = config('stubs.path').'/policy.plain.stub'; + } + + return file_exists($stub) ? $stub : parent::getStub(); + } + + /** + * Get the default namespace for the class. + * + * @param string $rootNamespace + * @return string + */ + protected function getDefaultNamespace($rootNamespace) + { + return $rootNamespace.config('stubs.namespaces.console'); + } +} diff --git a/src/Console/ProviderMakeCommand.php b/src/Console/ProviderMakeCommand.php new file mode 100644 index 0000000..5d13fd0 --- /dev/null +++ b/src/Console/ProviderMakeCommand.php @@ -0,0 +1,38 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace ATehnix\LaravelStubs\Console; + +use Illuminate\Foundation\Console\ProviderMakeCommand as BaseProviderMakeCommand; + +class ProviderMakeCommand extends BaseProviderMakeCommand +{ + /** + * Get the stub file for the generator. + * + * @return string + */ + protected function getStub() + { + $stub = config('stubs.path').'/provider.stub'; + + return file_exists($stub) ? $stub : parent::getStub(); + } + + /** + * Get the default namespace for the class. + * + * @param string $rootNamespace + * @return string + */ + protected function getDefaultNamespace($rootNamespace) + { + return $rootNamespace.config('stubs.namespaces.provider'); + } +} diff --git a/src/Console/RequestMakeCommand.php b/src/Console/RequestMakeCommand.php new file mode 100644 index 0000000..a435b6d --- /dev/null +++ b/src/Console/RequestMakeCommand.php @@ -0,0 +1,38 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace ATehnix\LaravelStubs\Console; + +use Illuminate\Foundation\Console\RequestMakeCommand as BaseRequestMakeCommand; + +class RequestMakeCommand extends BaseRequestMakeCommand +{ + /** + * Get the stub file for the generator. + * + * @return string + */ + protected function getStub() + { + $stub = config('stubs.path').'/request.stub'; + + return file_exists($stub) ? $stub : parent::getStub(); + } + + /** + * Get the default namespace for the class. + * + * @param string $rootNamespace + * @return string + */ + protected function getDefaultNamespace($rootNamespace) + { + return $rootNamespace.config('stubs.namespaces.request'); + } +} diff --git a/src/Console/SeederMakeCommand.php b/src/Console/SeederMakeCommand.php new file mode 100644 index 0000000..f58a4fa --- /dev/null +++ b/src/Console/SeederMakeCommand.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace ATehnix\LaravelStubs\Console; + +use Illuminate\Database\Console\Seeds\SeederMakeCommand as BaseSeederMakeCommand; + +class SeederMakeCommand extends BaseSeederMakeCommand +{ + /** + * Get the stub file for the generator. + * + * @return string + */ + protected function getStub() + { + $stub = config('stubs.path').'/seeder.stub'; + + return file_exists($stub) ? $stub : parent::getStub(); + } +} diff --git a/src/Console/StubsPublishCommand.php b/src/Console/StubsPublishCommand.php new file mode 100644 index 0000000..ccfb6fc --- /dev/null +++ b/src/Console/StubsPublishCommand.php @@ -0,0 +1,129 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace ATehnix\LaravelStubs\Console; + +use Illuminate\Console\Command; +use Illuminate\Filesystem\Filesystem; + +class StubsPublishCommand extends Command +{ + /** + * The console command name. + * + * @var string + */ + protected $name = 'stubs:publish'; + + /** + * The console command description. + * + * @var string + */ + protected $description = 'Publish any stub files from framework'; + + /** + * The filesystem instance. + * + * @var \Illuminate\Filesystem\Filesystem + */ + protected $files; + + /** + * Path to the Laravel Framework source directory + * + * @var string + */ + protected $frameworkPath = 'vendor/laravel/framework/src/'; + + /** + * Paths to stub files + * + * @var array + */ + protected $stubs = [ + 'Illuminate/Database/Console/Seeds/stubs/seeder.stub', + 'Illuminate/Foundation/Console/stubs/console.stub', + 'Illuminate/Foundation/Console/stubs/event.stub', + 'Illuminate/Foundation/Console/stubs/job.stub', + 'Illuminate/Foundation/Console/stubs/job-queued.stub', + 'Illuminate/Foundation/Console/stubs/listener.stub', + 'Illuminate/Foundation/Console/stubs/listener-queued.stub', + 'Illuminate/Foundation/Console/stubs/mail.stub', + 'Illuminate/Foundation/Console/stubs/model.stub', + 'Illuminate/Foundation/Console/stubs/notification.stub', + 'Illuminate/Foundation/Console/stubs/policy.plain.stub', + 'Illuminate/Foundation/Console/stubs/policy.stub', + 'Illuminate/Foundation/Console/stubs/provider.stub', + 'Illuminate/Foundation/Console/stubs/request.stub', + 'Illuminate/Foundation/Console/stubs/test.stub', + 'Illuminate/Routing/Console/stubs/controller.plain.stub', + 'Illuminate/Routing/Console/stubs/controller.stub', + 'Illuminate/Routing/Console/stubs/middleware.stub', + ]; + + /** + * Create a new command instance. + * + * @param \Illuminate\Filesystem\Filesystem $files + */ + public function __construct(Filesystem $files) + { + parent::__construct(); + + $this->files = $files; + } + + /** + * Execute the console command. + * + * @return void + */ + public function handle() + { + $path = config('stubs.path'); + $this->createDirectory($path); + + foreach ($this->stubs as $stub) { + $from = base_path($this->frameworkPath. $stub); + $to = $path . '/'. basename($stub); + $this->publishFile($from, $to); + } + } + + /** + * Publish the file to the given path. + * + * @param string $from + * @param string $to + * @return void + */ + protected function publishFile($from, $to) + { + if ($this->files->exists($to)) { + return; + } + + $this->files->copy($from, $to); + $this->info('Stub published: ' . basename($to)); + } + + /** + * Create the directory to house the published files if needed. + * + * @param string $directory + * @return void + */ + protected function createDirectory($directory) + { + if (! $this->files->isDirectory($directory)) { + $this->files->makeDirectory($directory, 0755, true); + } + } +} diff --git a/src/Console/TestMakeCommand.php b/src/Console/TestMakeCommand.php new file mode 100644 index 0000000..e6732a7 --- /dev/null +++ b/src/Console/TestMakeCommand.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace ATehnix\LaravelStubs\Console; + +use Illuminate\Foundation\Console\TestMakeCommand as BaseTestMakeCommand; + +class TestMakeCommand extends BaseTestMakeCommand +{ + /** + * Get the stub file for the generator. + * + * @return string + */ + protected function getStub() + { + $stub = config('stubs.path').'/test.stub'; + + return file_exists($stub) ? $stub : parent::getStub(); + } +} diff --git a/src/Providers/ArtisanServiceProvider.php b/src/Providers/ArtisanServiceProvider.php new file mode 100644 index 0000000..5f05f50 --- /dev/null +++ b/src/Providers/ArtisanServiceProvider.php @@ -0,0 +1,194 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace ATehnix\LaravelStubs\Providers; + +use ATehnix\LaravelStubs\Console; +use Illuminate\Foundation\Providers\ArtisanServiceProvider as BaseServiceProvider; + +class ArtisanServiceProvider extends BaseServiceProvider +{ + /** + * Bootstrapping the service provider. + * + * @return void + */ + public function boot() + { + $this->commands(Console\StubsPublishCommand::class); + } + + /** + * Register the command. + * + * @return void + */ + protected function registerConsoleMakeCommand() + { + $this->app->singleton('command.console.make', function ($app) { + return new Console\ConsoleMakeCommand($app['files']); + }); + } + + /** + * Register the command. + * + * @return void + */ + protected function registerControllerMakeCommand() + { + $this->app->singleton('command.controller.make', function ($app) { + return new Console\ControllerMakeCommand($app['files']); + }); + } + + /** + * Register the command. + * + * @return void + */ + protected function registerEventMakeCommand() + { + $this->app->singleton('command.event.make', function ($app) { + return new Console\EventMakeCommand($app['files']); + }); + } + + /** + * Register the command. + * + * @return void + */ + protected function registerJobMakeCommand() + { + $this->app->singleton('command.job.make', function ($app) { + return new Console\JobMakeCommand($app['files']); + }); + } + + /** + * Register the command. + * + * @return void + */ + protected function registerListenerMakeCommand() + { + $this->app->singleton('command.listener.make', function ($app) { + return new Console\ListenerMakeCommand($app['files']); + }); + } + + /** + * Register the command. + * + * @return void + */ + protected function registerMailMakeCommand() + { + $this->app->singleton('command.mail.make', function ($app) { + return new Console\MailMakeCommand($app['files']); + }); + } + + /** + * Register the command. + * + * @return void + */ + protected function registerMiddlewareMakeCommand() + { + $this->app->singleton('command.middleware.make', function ($app) { + return new Console\MiddlewareMakeCommand($app['files']); + }); + } + + /** + * Register the command. + * + * @return void + */ + protected function registerModelMakeCommand() + { + $this->app->singleton('command.model.make', function ($app) { + return new Console\ModelMakeCommand($app['files']); + }); + } + + /** + * Register the command. + * + * @return void + */ + protected function registerNotificationMakeCommand() + { + $this->app->singleton('command.notification.make', function ($app) { + return new Console\NotificationMakeCommand($app['files']); + }); + } + + /** + * Register the command. + * + * @return void + */ + protected function registerProviderMakeCommand() + { + $this->app->singleton('command.provider.make', function ($app) { + return new Console\ProviderMakeCommand($app['files']); + }); + } + + /** + * Register the command. + * + * @return void + */ + protected function registerRequestMakeCommand() + { + $this->app->singleton('command.request.make', function ($app) { + return new Console\RequestMakeCommand($app['files']); + }); + } + + /** + * Register the command. + * + * @return void + */ + protected function registerSeederMakeCommand() + { + $this->app->singleton('command.seeder.make', function ($app) { + return new Console\SeederMakeCommand($app['files'], $app['composer']); + }); + } + + /** + * Register the command. + * + * @return void + */ + protected function registerTestMakeCommand() + { + $this->app->singleton('command.test.make', function ($app) { + return new Console\TestMakeCommand($app['files']); + }); + } + + /** + * Register the command. + * + * @return void + */ + protected function registerPolicyMakeCommand() + { + $this->app->singleton('command.policy.make', function ($app) { + return new Console\PolicyMakeCommand($app['files']); + }); + } +} diff --git a/src/Providers/ConsoleSupportServiceProvider.php b/src/Providers/ConsoleSupportServiceProvider.php new file mode 100644 index 0000000..a80b49a --- /dev/null +++ b/src/Providers/ConsoleSupportServiceProvider.php @@ -0,0 +1,60 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace ATehnix\LaravelStubs\Providers; + +use Illuminate\Foundation\Providers\ConsoleSupportServiceProvider as BaseServiceProvider; + +class ConsoleSupportServiceProvider extends BaseServiceProvider +{ + /** + * The provider class names. + * + * @var array + */ + protected $providers = [ + 'ATehnix\LaravelStubs\Providers\ArtisanServiceProvider', + 'Illuminate\Console\ScheduleServiceProvider', + 'Illuminate\Database\MigrationServiceProvider', + 'Illuminate\Database\SeedServiceProvider', + 'Illuminate\Foundation\Providers\ComposerServiceProvider', + 'Illuminate\Queue\ConsoleServiceProvider', + ]; + + /** + * Path to the config file + * + * @var string + */ + protected $configPath = __DIR__.'/../../publish/config/stubs.php'; + + /** + * Register the service provider. + * + * @return void + */ + public function register() + { + $this->mergeConfigFrom($this->configPath, 'stubs'); + + parent::register(); + } + + /** + * Bootstrapping the service provider. + * + * @return void + */ + public function boot() + { + $this->publishes([ + $this->configPath => config_path('stubs.php'), + ]); + } +}