Laravel中的make控制器错误 [英] Error in make controller in laravel
问题描述
我想学习幼虫,请帮忙.
使用laravel 5.0.16版.
php artisan make:controller Admin\Controller --resource
它显示此错误:
[RuntimeException]"--resource"选项不存在.
出什么问题了?
有什么区别?
php artisan make:controller Admin\Controller --resource
php artisan make:controller Admin\Controller --plain
php artisan make:controller Admin\Controller
--resource
的第1个在5.0中不存在,并且您在Admin/Controller上面编写时在控制器名称中不使用/使其成为AdminController >
短
现在在Laravel 5.2 make:controller
命令中创建普通控制器,如果要成为资源控制器,则需要添加--resource
资源控制器
资源控制器还提供了四种带有路由的CRUD内置方法,例如,您运行:
php artisan make:controller AdminController --resource
然后可以将路线注册为:
Route::resource('admin', 'AdminController');
它将为您提供四种方法.
创建检索更新删除
Laravel资源路由通过单行代码即可将典型的"CRUD"路由分配给控制器.
没有-plain的普通控制器.
之前,Laravel 5.2 --plain
用于制作没有内置路由和方法的简单控制器.现在:
php artisan make:controller AdminController
与--plain
相同.
参考: https://laravel.com/docs/5.4/controllers
I want learn larvel please help.
Using laravel version 5.0.16.
php artisan make:controller Admin\Controller --resource
It shows this error:
[RuntimeException] The "--resource" option does not exist.
What is the problem?
What is different between?
php artisan make:controller Admin\Controller --resource
php artisan make:controller Admin\Controller --plain
php artisan make:controller Admin\Controller
1st of all --resource
does not exist in 5.0 and don't use / in controller name as you write above Admin/Controller make it as AdminController
Short
Now in Laravel 5.2 make:controller
command creates plain controller, if you want to make resource controller you need to add --resource
Resource Controller
Resource controller gives four built-in methods of CRUD with routes as well, for example you run:
php artisan make:controller AdminController --resource
Then the routes can be registered as:
Route::resource('admin', 'AdminController');
It will give you four methods.
Create Retrieve Update Delete
Laravel resource routing assigns the typical "CRUD" routes to a controller with a single line of code.
Plain Controller and without --plain.
Before, Laravel 5.2 --plain
was used to make a simple controller without builtin routes and methods. Now:
php artisan make:controller AdminController
Works the same as --plain
.
Reference: https://laravel.com/docs/5.4/controllers
这篇关于Laravel中的make控制器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!