1

here's the code

Route::get('run-cmd', function() {
    Artisan::call('make:controller HelloController');
});

and I wonder I'm getting this error...

InvalidArgumentException in Application.php line 549:
Command "make:controller HelloController" is not defined.
Did you mean one of these?
make:migration
make:controller
make:middleware
make:request
make:provider
make:console
make:event
make:model
make:command

what's wrong?

bobD
  • 1,037
  • 2
  • 9
  • 17
  • Did you install all your composer dependencies? `composer install`. If so, try `composer dump-autoload` – Pistachio Aug 28 '16 at 21:22
  • well I think the problem must be something else , not composer dependencies, because the command "migrate" is working well , but the commands that need a parameter to be passed fail, ? – bobD Aug 28 '16 at 21:33
  • 2
    try that Artisan::call('make:controller', ['name' => 'HelloController']); – ABDEL-RHMAN Aug 28 '16 at 21:34
  • @ABDEL-RHMAN worked! , exactly what I wanted, but how about other things? maybe a '--help' parameter? Is there a complete source for It or you just guessed the 'name' keyword? – bobD Aug 28 '16 at 21:37
  • @bobD yes, just type php artisan make:controller -h and you get needed parameters – ABDEL-RHMAN Aug 28 '16 at 21:39
  • @ABDEL-RHMAN got It, thank you :) – bobD Aug 28 '16 at 21:49

1 Answers1

1

Replace

Artisan::call('make:controller HelloController');

with

Artisan::call('make:controller', [ 'name' => 'HelloController' ]);
Baum mit Augen
  • 49,044
  • 25
  • 144
  • 182
Bahman Parsa Manesh
  • 2,314
  • 3
  • 16
  • 32