BadMethodCallException in Macroable.php line 74 :

2019-04-29 03:22发布

I'm getting little bit issue when I follow Route Controller.

Web.php Code:

{"
Route::controller('/admin','adminController');
"}

adminController.php Code:

{"
<?php
namespace App\Http\Controllers;
class adminController extends Controller{
public function getDashboard(){
echo " Get Dashborad Method ";
}}
"}

When I hit http://localhost:8000/admin/dashboard an error:

Display ("BadMethodCallException in Macroable.php line 74 : Method controller does not exist.")

Here is SnapShot:

http://take.ms/3NqA4

Please take a look and let me know what is wrong with code.

标签: laravel-5
2条回答
兄弟一词,经得起流年.
2楼-- · 2019-04-29 03:41

faced the same problem recently. Laravel 5.3 does not support Route::controller() method. You need to change it to Route::get(). Please see how it use here https://laravel.com/docs/5.3/routing#basic-routing.

查看更多
Root(大扎)
3楼-- · 2019-04-29 04:04

Please also make sure you don't use any namespace inside your routes file.

E.g. If by mistake your IDE add's

use Illuminate\Routing\Route;

It could result in the same error mentioned above. Your route file (web.php or api.php) should not use the Illuminate\Routing\Route class.

EDIT: Tested on Laravel 5.5

查看更多
登录 后发表回答