Ivan nbn Ivan nbn - 1 month ago 9
PHP Question

Artisan doesn't generate create, store etc. in controller

So I'm using laravel, and when creating a controller with artisan it creates it without the create, store etc. things.

It outputs this:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;

class TasksController extends Controller
{
//
}


Shouldn't it generate index/create/store etc? If not, how do I generate them?

Answer

With Laravel 5.2 and before, you just ran something like this:

php artisan make:controller TasksController

And that generated the stubs for you. You had to explicitly pass a --plain to opt out of the stubbed methods. As of Laravel 5.3 and above, you need to add --resource in order for it to stub those methods and it defaults to the plain version:

php artisan make:controller TasksController --resource

Which will stub the resource methods for you. This was changed in this commit: https://github.com/laravel/framework/commit/8e6ac01b4a311ec4740ab2bced01fbdf6f1241c5

Comments