Symfony 404找不到" GET / admin / users /"

时间:2018-05-14 22:34:19

标签: symfony symfony4 symfony-routing

配置/ routes.yaml

admin_users:
    resource: '@ProjectUserBundle/Resources/config/routing.yml'
    prefix: /admin

app_locations:
    resource: '../src/Project/LocationBundle/Controller/'
    type:     annotation

项目/ UserBundle /资源/配置/ routing.yaml

admin_userslist:
    path: /users
    controller: ProjectUserBundle:Users:index

admin_useradd:
    path: /user/add
    defaults:
    controller: ProjectUserBundle:Users:add

admin_useredit:
    path: /user/edit/{id}
    defaults:
    controller: ProjectUserBundle:Users:edit

admin_usershow:
    path: /user/show/{id}
    defaults:
    controller: ProjectUserBundle:Users:show

php bin / console debug:router - >输出

  homepage                   ANY      ANY      ANY    /
  _twig_error_test           ANY      ANY      ANY    /_error/{code}.{_format}
  _wdt                       ANY      ANY      ANY    /_wdt/{token}
  _profiler_home             ANY      ANY      ANY    /_profiler/
  _profiler_search           ANY      ANY      ANY    /_profiler/search
  _profiler_search_bar       ANY      ANY      ANY    /_profiler/search_bar
  _profiler_phpinfo          ANY      ANY      ANY    /_profiler/phpinfo
  _profiler_search_results   ANY      ANY      ANY    /_profiler/{token}/search/results
  _profiler_open_file        ANY      ANY      ANY    /_profiler/open
  _profiler                  ANY      ANY      ANY    /_profiler/{token}
  _profiler_router           ANY      ANY      ANY    /_profiler/{token}/router
  _profiler_exception        ANY      ANY      ANY    /_profiler/{token}/exception
  _profiler_exception_css    ANY      ANY      ANY    /_profiler/{token}/exception.css
  admin_userslist            ANY      ANY      ANY    /admin/users
  admin_useradd              ANY      ANY      ANY    /admin/user/add
  admin_useredit             ANY      ANY      ANY    /admin/user/edit/{id}
  admin_usershow             ANY      ANY      ANY    /admin/user/show/{id}
  admin_locations_index      ANY      ANY      ANY    /admin/locations/
  admin_location_add         ANY      ANY      ANY    /admin/locations/add

php bin / console debug:router admin_userslist - >输出

+--------------+----------------------------------------------------------------+
| Property     | Value                                                          |
+--------------+----------------------------------------------------------------+
| Route Name   | admin_userslist                                                |
| Path         | /admin/users                                                   |
| Path Regex   | #^/admin/users$#sD                                             |
| Host         | ANY                                                            |
| Host Regex   |                                                                |
| Scheme       | ANY                                                            |
| Method       | ANY                                                            |
| Requirements | NO CUSTOM                                                      |
| Class        | Symfony\Component\Routing\Route                                |
| Defaults     | _controller: ProjectUserBundle:Users:index                     |
| Options      | compiler_class: Symfony\Component\Routing\RouteCompiler        |
| Callable     | App\Project\UserBundle\Controller\UsersController::indexAction |
+--------------+----------------------------------------------------------------+

如果我点击example.com/admin/users/ 我收到了这个错误 - >见标题, 有谁知道什么呢?

谢谢!

1 个答案:

答案 0 :(得分:0)

在config / routes.yaml中你写道:

resource: '@ProjectUserBundle/Resources/config/routing.yml'

扩展名为.yml。但是你的文件是routing.yaml,.yaml扩展名。不是吗?