我正在将用Laravel 4.2编写的应用程序升级到Laravel 5.2。 我的控制器有很长的命名空间,并希望缩短它们。
例如:
CustomServiceProvider.php
public function register()
{
$this->app->bind('Shortname\Somecontroller', 'Really\Really\Long\Name\Somecontroller');
}
routes.php文件
$router->get('someroute', ['uses' => 'Shortname\Somecontroller@someFunction']);
可以在自定义服务提供商内部使用,并且可以在Laravel 4.2和Larave 5.1中使用。在我开始迁移到Laravel 5.2后,它停止了工作。
最近我解决的问题是这个问题报告:https://github.com/laravel/framework/issues/14920但它也不起作用。
这适用于例如:
routes_alternative.php
$router->get('someroute', ['uses' => 'Really\Really\Long\Name\Somecontroller@someFunction']);
我已尝试Really\Really\Long\Name\Somecontroller::class
并将所有内容移至RouteServiceProvider
。我还尝试了artisan route:clear
,artisan cache:clear
,artisan dump-autoload
,artisan clear-compiled
以及各种其他作曲家和工匠诡计。
所有操作都会导致异常:
Route.php第280行中的ReflectionException: 类Shortname \ Somecontroller不存在
有人有类似的经验并且能够解决它吗?