Error message
InvalidArgumentException in RouteRegistrar.php line 75:
Attribute [controllers] does not exist.
Source Code:
Route::controllers([
'lists' => 'ListsController',
'tasks' => 'TasksController',
]);
Reason
Route::controllers method (Implicit controller) defining series of URIs and associated controllers, reflection is used parse and register all of the controller’s routable methods. However, this controller method in route is deprecated since 5.2 (or 5.3, i can't sure) but it works at 5.1 (according to user: SaeedPrez at https://laracasts.com/discuss/ and RïshïKêsh Kümar ay https://stackoverflow.com), check your laravel version.Method 1
You can use this laravel routes publisher package to replace deprecated Route::controller() and Route::controllers() with explicit routes:https://github.com/themsaid/laravel-routes-publisher.
Method 2
You can use the resource method (RESTful Resource controller) which get similar purpose with controller method (Implicit controller):https://stackoverflow.com/questions/23505875/laravel-routeresource-vs-routecontroller
Example code
Using Route::resource method:Route::resource('lists','ListsController');but you also need to change the controllers method name such as something like:
Route::resource('tasks','TasksController');
From :
<?php namespace example\Http\Controllers;To:
class ListsController extends Controller {
public function getIndex()
{
return view('lists.index');
}
public function getCreate()
{
return view('lists.create');
}
public function postStore()
{
return view('lists.store')
}
}
?>
<?php namespace example\Http\Controllers;For detail of RESTful Resource controller and Implicit controller, you can reference from the answer at stackoverflow.com by RyanWinchester :
class ListsController extends BaseController {
public function index() {
return view('lists.index');
}
public function create()
{
return view('lists.create');
}
public function store()
{
return view('lists.store')
}
}
https://stackoverflow.com/questions/23505875/laravel-routeresource-vs-routecontroller
and resource controller doc with laravel 5.4 :
https://laravel.com/docs/5.4/controllers#resource-controllers
Reference
https://laracasts.com/discuss/channels/laravel/implicit-controllers-laravel-54https://laracasts.com/discuss/channels/laravel/routecontrollers-in-laravel-54
https://stackoverflow.com/questions/43572635/php-laravel-attribute-controller-does-not-exist
No comments :
Post a Comment