I have this in routes.php :
Route::post('myFunction', ['uses' => 'MyPackage\MyController@updateMeta']);
And I get this error :
ReflectionException in Route.php line 280:
Class App\Http\Controllers\MyPackage\MyController does not exist
Any idea how to use controller from vendor in routes.php ?
Place another \\
in front of the namespace. By default, Laravel will search for controllers in App\\Http\\Controllers\\
. By placing another \\
in front you tell Laravel to start searching in the root namespace.
Route::post('myFunction', ['uses' => '\MyPackage\MyController@updateMeta']);
You should add '\\' in the beginning of the controller namespace:
By default, routes.php assumes your controller is in 'App\\Http\\Controllers' namespace but adding '\\' will cause it to look in the root namespace.
Route::get('/vendor-control', '\Vendor1\Vendormanager\controllers\Vendor1Controller@view');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.