0

I want to all route namelist, actionlist and other data inside of controller in laravel 5.0 by using Symfony\Component\Routing\Annotation\Route;component

I've used below code in view it will word as well but if I used in Controller I will get errors

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

Errors happen when I used this method in Controller.

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

This is the result if i used those methods inside of views

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

1 回答 1

-1

尝试在控制器中添加以下行:

use Illuminate\Support\Facades\Route;
于 2016-08-25T08:20:20.423 回答