├── .gitignore ├── composer.json ├── src ├── MakeServiceProvider.php └── Commands │ └── MakeCommand.php ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor/ 2 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "laracademy/interactive-make", 3 | "description": "Interactive make CLI replacement for Laravel", 4 | "license": "MIT", 5 | "authors": [ 6 | { 7 | "name": "Michael McMullen", 8 | "email": "packages@laracademy.co" 9 | } 10 | ], 11 | "require": {}, 12 | "minimum-stability": "dev", 13 | "autoload": { 14 | "psr-4": { 15 | "Laracademy\\Commands\\": "src/" 16 | } 17 | }, 18 | "extra": { 19 | "laravel": { 20 | "providers": [ 21 | "Laracademy\\Commands\\MakeServiceProvider" 22 | ] 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/MakeServiceProvider.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | use Illuminate\Support\ServiceProvider; 11 | 12 | class MakeServiceProvider extends ServiceProvider 13 | { 14 | /** 15 | * Indicates if loading of the provider is deferred. 16 | * 17 | * @var bool 18 | */ 19 | protected $defer = false; 20 | 21 | public function boot() 22 | { 23 | // 24 | } 25 | 26 | public function register() 27 | { 28 | $this->registerModelGenerator(); 29 | } 30 | 31 | private function registerModelGenerator() 32 | { 33 | $this->app->singleton('command.laracademy.make', function ($app) { 34 | return $app['Laracademy\Commands\Commands\MakeCommand']; 35 | }); 36 | 37 | $this->commands('command.laracademy.make'); 38 | } 39 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Michael McMullen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Interactive Make for Laravel 5.4 2 | 3 | [![Latest Stable Version](https://poser.pugx.org/laracademy/interactive-make/v/stable)](https://packagist.org/packages/laracademy/interactive-make) [![Total Downloads](https://poser.pugx.org/laracademy/interactive-make/downloads)](https://packagist.org/packages/laracademy/interactive-make) [![Latest Unstable Version](https://poser.pugx.org/laracademy/interactive-make/v/unstable)](https://packagist.org/packages/laracademy/interactive-make) [![License](https://poser.pugx.org/laracademy/interactive-make/license)](https://packagist.org/packages/laracademy/interactive-make) 4 | 5 | ## Getting Started 6 | 7 | To get started you need to install the package with Composer: 8 | 9 | ```bash 10 | composer require laracademy/interactive-make 11 | ``` 12 | 13 | ### Laravel >= 5.5 14 | 15 | That's it! The package is auto-discovered on 5.5 and up! 16 | 17 | ### Laravel <= 5.4 18 | 19 | Add the package service provider to your providers array in `config/app.php` 20 | 21 | ```php 22 | 'providers' => [ 23 | // ... 24 | Laracademy\Commands\MakeServiceProvider::class, 25 | ], 26 | ``` 27 | 28 | To start using this package, run this command in your terminal and follow the onscreen prompts: 29 | 30 | ```bash 31 | php artisan make 32 | ``` 33 | 34 | ### Preview 35 | 36 | ![](http://i.imgur.com/qR8AQ4U.gif) 37 | 38 | 39 | 40 | ## Disclaimer 41 | 42 | 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. 43 | -------------------------------------------------------------------------------- /src/Commands/MakeCommand.php: -------------------------------------------------------------------------------- 1 | 'Auth', 18 | 'controller' => 'Controller', 19 | 'channel' => 'Channel', 20 | 'command' => 'Command', 21 | 'component' => 'Component', 22 | 'event' => 'Event', 23 | 'exception' => 'Exception', 24 | 'factory' => 'Factory', 25 | 'job' => 'Job', 26 | 'listener' => 'Listener', 27 | 'mail' => 'Mail', 28 | 'middleware' => 'Middleware', 29 | 'migration' => 'Migration', 30 | 'model' => 'Model', 31 | 'notification' => 'Notification', 32 | 'observer' => 'Observer', 33 | 'policy' => 'Policy', 34 | 'provider' => 'Provider', 35 | 'request' => 'Request', 36 | 'resource' => 'Resource', 37 | 'rule' => 'Rule', 38 | 'seeder' => 'Seeder', 39 | 'test' => 'Test', 40 | ]; 41 | 42 | protected $options; 43 | 44 | /** 45 | * The console command description. 46 | * 47 | * @var string 48 | */ 49 | protected $description = 'Interactive Make Commands'; 50 | 51 | /** 52 | * Create a new command instance. 53 | * 54 | * @return void 55 | */ 56 | public function __construct() 57 | { 58 | parent::__construct(); 59 | 60 | $this->availableCommands = collect($this->availableCommands); 61 | } 62 | 63 | /** 64 | * Execute the console command. 65 | * 66 | * @return mixed 67 | */ 68 | public function handle() 69 | { 70 | 71 | // Ask what command 72 | $command = $this->choice('What command are you running?', $this->availableCommands->toArray()); 73 | 74 | if (!$this->availableCommands->has($command)) { 75 | $this->info('The specified command does not exist.'); 76 | return; 77 | } 78 | 79 | $method = 'make' . ucfirst($command); 80 | call_user_func([$this, $method]); 81 | 82 | $this->call('make:'. $command, $this->options); 83 | } 84 | 85 | /** 86 | * all options for make:auth() 87 | */ 88 | public function makeAuth() 89 | { 90 | // Views Only 91 | if ($this->confirm('Only scaffold the authentication views?')) { 92 | $this->options['--views'] = ''; 93 | } 94 | 95 | if ($this->confirm('Overwrite existing views by default')) { 96 | $this->options['--force'] = ''; 97 | } 98 | } 99 | 100 | /** 101 | * all options for make:controller 102 | */ 103 | public function makeController() 104 | { 105 | $this->options['name'] = ucfirst($this->ask('Controller Name (Example: MyController)')); 106 | 107 | // Resourceful Controller 108 | if ($this->confirm('Is this controller resourceful?')) { 109 | $this->options['-r'] = '--resource'; 110 | } 111 | 112 | // Model Controller 113 | if ($this->confirm('Would you like to use route model binding?')) { 114 | $this->options['--model'] = $this->ask('Please enter the name of the model'); 115 | } 116 | } 117 | 118 | /** 119 | * all options for make:channel 120 | */ 121 | public function makeChannel() 122 | { 123 | $this->options['name'] = $this->ask('Channel Name (Example: MyChannel)'); 124 | } 125 | 126 | /** 127 | * all options for make:command 128 | */ 129 | public function makeCommand() 130 | { 131 | $this->options['name'] = $this->ask('Command Name (Example: MyCommand)'); 132 | 133 | // Command Name 134 | $this->options['--command'] = $this->ask('Please enter the command name', 'command:name'); 135 | } 136 | 137 | /** 138 | * all options for make:component 139 | */ 140 | public function makeComponent() 141 | { 142 | $this->options['name'] = $this->ask('Component Name (Example: MyComponent)'); 143 | 144 | // Force 145 | if ($this->confirm('Create the class even if the component already exists?')) { 146 | $this->options['--force'] = ''; 147 | } 148 | 149 | // Inline 150 | if ($this->confirm('Create a component that renders an inline view?')) { 151 | $this->options['--inline'] = ''; 152 | } 153 | } 154 | 155 | /** 156 | * all options for make:event 157 | */ 158 | public function makeEvent() 159 | { 160 | $this->options['name'] = $this->ask('Event Name (Example: MyEvent)'); 161 | } 162 | 163 | /** 164 | * all options for make:exception 165 | */ 166 | public function makeException() 167 | { 168 | $this->options['name'] = $this->ask('Exception Name (Example: MyException)'); 169 | } 170 | 171 | /** 172 | * all options for make:factory 173 | */ 174 | public function makeFactory() 175 | { 176 | $this->options['--model'] = $this->ask('Please enter the name of the model to create a factory for'); 177 | $this->options['name'] = ucfirst($this->options['--model'])."Factory"; 178 | } 179 | 180 | /** 181 | * all options for make:job 182 | */ 183 | public function makeJob() 184 | { 185 | $this->options['name'] = $this->ask('Job Name (Example: MyJob)'); 186 | 187 | // Synchronous 188 | if ($this->confirm('Is this job synchronos?')) { 189 | $this->options['--sync'] = ''; 190 | } 191 | } 192 | 193 | /** 194 | * all options for make:listener 195 | */ 196 | public function makeListener() 197 | { 198 | $this->options['name'] = $this->ask('Listener Name (Example: MyListener)'); 199 | 200 | if ($this->confirm('Do you know the event to listen for?')) { 201 | $this->options['--event'] = $this->ask('The event class being listened for', ''); 202 | } 203 | 204 | if ($this->confirm('Will this event be queued')) { 205 | $this->options['--queued'] = ''; 206 | } 207 | } 208 | 209 | /** 210 | * all options for make:mail 211 | */ 212 | public function makeMail() 213 | { 214 | $this->options['name'] = $this->ask('Mail Name (Example: MyMail)'); 215 | 216 | if ($this->confirm('Would you like to create a template for this mail command?')) { 217 | $this->options['--markdown'] = strtolower($this->options['name']); 218 | } 219 | } 220 | 221 | /** 222 | * all options for make:middleware 223 | */ 224 | public function makeMiddleware() 225 | { 226 | $this->options['name'] = $this->ask('Middleware Name (Example: MyMiddlware)'); 227 | } 228 | 229 | /** 230 | * all options for make:migration 231 | */ 232 | public function makeMigration() 233 | { 234 | $tableName = $this->ask('Table Name (Example: users)'); 235 | 236 | if ($this->confirm('Are you creating a new table')) { 237 | $this->info('Setting create option for table '. $tableName); 238 | 239 | $this->options['--create'] = $tableName; 240 | $this->options['name'] = 'create_'. $tableName .'_table'; 241 | } else { 242 | $this->info('Setting table option for table '. $tableName); 243 | 244 | $this->options['name'] = $this->ask('Migration Name (Example: alter_user_table_add_column_is_admin)', 'alter_'. $tableName .'_table_add'); 245 | $this->options['--table'] = $tableName; 246 | } 247 | 248 | if (! $this->confirm('Use default migration folder?', 'yes')) { 249 | $this->options['path'] = $this->ask('Path for Migration'); 250 | } 251 | } 252 | 253 | /** 254 | * all options for make:model 255 | */ 256 | public function makeModel() 257 | { 258 | $this->options['name'] = $this->ask('Model Name (Example: Posts)'); 259 | 260 | if ($this->confirm('Do you want to make a migration for this model?')) { 261 | $this->options['-m'] = '--migration'; 262 | } 263 | 264 | if ($this->confirm('Do you want to make a controller for this model?')) { 265 | $this->options['-c'] = '--controller'; 266 | 267 | if ($this->confirm('Is this controller a resourceful controller?')) { 268 | $this->options['-r'] = '--resource'; 269 | } 270 | } 271 | } 272 | 273 | /** 274 | * all options for make:notification 275 | */ 276 | public function makeNotification() 277 | { 278 | $this->options['name'] = $this->ask('Notification Name (Example: MyNotification)'); 279 | 280 | if ($this->confirm('Would you like to create a template for this notification command?')) { 281 | $this->options['--markdown'] = strtolower($this->options['name']); 282 | } 283 | } 284 | 285 | /** 286 | * all options for make:observer 287 | */ 288 | public function makeObserver() 289 | { 290 | $this->options['name'] = $this->ask('Observer Name (Example: MyObserver)'); 291 | } 292 | 293 | /** 294 | * all options for make:policy 295 | */ 296 | public function makePolicy() 297 | { 298 | $this->options['name'] = $this->ask('Policy Name (Example: MyPolicy)'); 299 | 300 | if ($this->confirm('Will this policy apply to a model')) { 301 | $this->options['--model'] = $this->ask('Model class name'); 302 | } 303 | } 304 | 305 | /** 306 | * all options for make:provider 307 | */ 308 | public function makeProvider() 309 | { 310 | $this->options['name'] = $this->ask('Provider Name (Example: MyProvider)'); 311 | } 312 | 313 | /** 314 | * all options for make:request 315 | */ 316 | public function makeRequest() 317 | { 318 | $this->options['name'] = $this->ask('Request Name (Example: MyRequest)'); 319 | } 320 | 321 | /** 322 | * all options for make:resource 323 | */ 324 | public function makeResource() 325 | { 326 | $this->options['name'] = $this->ask('Resource Name (Example: MyResource)'); 327 | } 328 | 329 | /** 330 | * all options for make:rule 331 | */ 332 | public function makeRule() 333 | { 334 | $this->options['name'] = $this->ask('Request Name (Example: NewRule)'); 335 | } 336 | 337 | /** 338 | * all options for make:seeder 339 | */ 340 | public function makeSeeder() 341 | { 342 | $this->options['name'] = $this->ask('Seeder Name (Example: MySeeder)'); 343 | } 344 | 345 | /** 346 | * all options for make:test 347 | */ 348 | public function makeTest() 349 | { 350 | $this->options['name'] = $this->ask('Test Name (Example: MyTest)'); 351 | 352 | if ($this->confirm('Is this test a Unit test?')) { 353 | $this->options['--unit'] = '--unit'; 354 | } 355 | } 356 | } 357 | --------------------------------------------------------------------------------