phplaravellaravel-5laravel-artisan

Run artisan command in laravel 5


I have controller like this

 public function store(Request $request)
{
   Artisan::call("php artisan infyom:scaffold {$request['name']} --fieldsFile=public/Product.json");
}

Show me error

There are no commands defined in the "php artisan infyom" namespace.

When I run this command in CMD it work correctly


Solution

  • You need to remove php artisan part and put parameters into an array to make it work:

    public function store(Request $request)
    {
       Artisan::call("infyom:scaffold", ['name' => $request['name'], '--fieldsFile' => 'public/Product.json']);
    }
    

    https://laravel.com/docs/5.2/artisan#calling-commands-via-code