且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Laravel 4中访问包控制器

更新时间:2022-06-25 06:32:24

错误是在路由中包括了控制器路径.我有以下内容:

The mistake was including the controllers path in the route. I had the following:

Route::get('/package', 'Vendor\Package\Controllers\HomeController@showWelcome');

正确的用法是:

Route::get('/package', 'Vendor\Package\HomeController@showWelcome');

控制器中包含命名空间:

With the namespace included in the controller:

namespace Vendor\Package;

控制器应扩展照明:

\Illuminate\Routing\Controllers\Controller

仍然不能使用包名称(例如:Package :: HomeController @ showWelcome),但是我可以使用名称空间.耶.

Still can't use the package name (eg: Package::HomeController@showWelcome), but I can using the namespace. yay.

问题解决了.