0
votes

I'm trying to call a artisan command from code. The command I want to execute is a command from the pingpong package and is as follows:

 php artisan module:make Test

I'm doing this with the following code:

Artisan::call('module:make Test');

The error I'm getting is: Command "module:make Test" is not defined. While this is certainly a good command.

Parameters could be given with an array like:

Artisan::call('module:make', [
     'Test'
]);

But these parameters are only for flags I guess. Cause this command does nothing. No error. It just returns 0.

Same kind of question asked here: https://github.com/pingpong-labs/modules/issues/202

2

2 Answers

0
votes

Looks like the name of the parameter is simply name, so you should be able to call it like this:

Artisan::call('module:make', [
     'name' => 'Test'
]);

Sources: https://github.com/pingpong-labs/modules/blob/master/Commands/MakeCommand.php, http://laravel.com/docs/5.1/artisan#calling-commands-via-code

0
votes

To create a new module with pingpong package use:

Artisan::call('module:make', array(
    'name' => array('Test'),
));

Don't forget to place the code inside a route and not outside, like me.