Created
April 2, 2018 15:45
-
-
Save ar-android/922045989668cde9d5fcad672ba4470c to your computer and use it in GitHub Desktop.
Class for generating lumen controller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Console\Commands; | |
use Illuminate\Console\GeneratorCommand; | |
use Symfony\Component\Console\Input\InputOption; | |
class ControllerMakeCommand extends GeneratorCommand | |
{ | |
/** | |
* The console command name. | |
* | |
* @var string | |
*/ | |
protected $name = 'make:controller'; | |
/** | |
* The console command description. | |
* | |
* @var string | |
*/ | |
protected $description = 'Create a new controller class'; | |
/** | |
* The type of class being generated. | |
* | |
* @var string | |
*/ | |
protected $type = 'Controller'; | |
/** | |
* Get the stub file for the generator. | |
* | |
* @return string | |
*/ | |
protected function getStub() | |
{ | |
if ($this->option('resource')) { | |
return __DIR__.'/stubs/controller.stub'; | |
} | |
return __DIR__.'/stubs/controller.plain.stub'; | |
} | |
/** | |
* Get the default namespace for the class. | |
* | |
* @param string $rootNamespace | |
* @return string | |
*/ | |
protected function getDefaultNamespace($rootNamespace) | |
{ | |
return $rootNamespace.'\Http\Controllers'; | |
} | |
/** | |
* Get the console command options. | |
* | |
* @return array | |
*/ | |
protected function getOptions() | |
{ | |
return [ | |
['resource', null, InputOption::VALUE_NONE, 'Generate a resource controller class.'], | |
]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment