2016-08-25 49 views
0

我想所有的航線名稱列表,和的ActionList在laravel 5.0控制器內其他數據使用RouteCollection;組件如何使用的Symfony 分量路由註釋路徑在Laravel5.0

我下面用代碼鑑於其告字很好,但如果我在控制器中使用,我會得到錯誤

$routes = Route::getRoutes(); 
    dd($routes); 

錯誤發生時,我用控制器此方法。

FatalErrorException in Handler.php line 26: 
Uncaught TypeError: Argument 1 passed to App\Exceptions\Handler::report() must be an instance of Exception, instance of Error given, 
called in vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php on line 73 and defined in 
.../app/Exceptions/Handler.php:26 
Stack trace: 
#0 /vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(73): App\Exceptions\Handler->report(Object(Error)) 
#1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(Error)) 
#2 {main} 
thrown 

這是結果,如果我使用的內部意見的方法

#routes: array:3 [▶] 
    #allRoutes: array:329 [▶] 
    #nameList: array:260 [▶] 
    #actionList: array:325 [▶] 

回答

-1

嘗試添加下面一行在你的控制器:

use Illuminate\Support\Facades\Route;