laravel 使用命令行创建控制器时缺少 Illuminate 的参数 2

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24600814/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 09:47:01  来源:igfitidea点击:

Missing argument 2 for Illuminate when using command line to create controller

command-linelaravellaravel-4code-generation

提问by Joseph Girgis

I am trying to create controller using the command line in laravel but when i SSH to my server and try to run the laravel CLI command php artisan controller:make AboutControlleror even any other command like : php artisan list

我正在尝试使用 laravel 中的命令行创建控制器,但是当我通过 SSH 连接到我的服务器并尝试运行 laravel CLI 命令php artisan controller:make AboutController甚至任何其他命令时,例如:php artisan list

I always get this message :

我总是收到这条消息:

{
"error":
  {
    "type":"ErrorException",
    "message":"Missing argument 2 for Illuminate\Routing\Router::controller(), called in \/home1\/jokira\/public_html\/laravel\/bootstrap\/compiled.php on line 3155 and defined","file":"\/home1\/jokira\/public_html\/laravel\/bootstrap\/compiled.php","line":4379
  }
}

What am i doing wrong ?

我究竟做错了什么 ?

回答by zhzhwcn

Maybe you add some wrong routes to app/routes.php just like what I did. I add some temp route like this:

也许你像我所做的那样在 app/routes.php 中添加了一些错误的路由。我添加了一些这样的临时路线:

    //user routes
    Route::get('/login');
    Route::post('/login');
    Route::get('/reg');
    Route::post('/reg');

And I got the same errors as you .

我和你有同样的错误。

After I deleted this lines , all works fine now.

删除此行后,现在一切正常。

Wish can help you .

愿能帮到你。

回答by Ifan Iqbal

You need to specify the path of the route for your controller.

您需要为控制器指定路由的路径。

This is wrong example: Route::controller('AuthController');

这是错误的例子: Route::controller('AuthController');

And this is the correct one: Route::controller('/auth', 'AuthController');

这是正确的: Route::controller('/auth', 'AuthController');