我对Symfony路线非常困惑。
我在下面有这个文件,我无法理解不同的关键字。例如,我不知道“前缀”如何工作或“模式”如何工作
fos_user_security:
resource: "@FOSUserBundle/Resources/config/routing/security.xml"
fos_user_profile:
resource: "@FOSUserBundle/Resources/config/routing/profile.xml"
prefix: /profile
fos_user_register:
resource: "@FOSUserBundle/Resources/config/routing/registration.xml"
prefix: /register
fos_user_resetting:
resource: "@FOSUserBundle/Resources/config/routing/resetting.xml"
prefix: /resetting
fos_user_change_password:
resource: "@FOSUserBundle/Resources/config/routing/change_password.xml"
prefix: /profile
#HWIOAuthBundle routes
hwi_oauth_security:
resource: "@HWIOAuthBundle/Resources/config/routing/login.xml"
prefix: /login
hwi_oauth_connect:
resource: "@HWIOAuthBundle/Resources/config/routing/connect.xml"
prefix: /login
hwi_oauth_redirect:
resource: "@HWIOAuthBundle/Resources/config/routing/redirect.xml"
prefix: /login
facebook_login:
pattern: /login/check-facebook
google_login:
pattern: /login/check-google
stefano_zulli:
resource: "@StefanoZulliBundle/Resources/config/routing.yml"
prefix: /
答案 0 :(得分:0)
模式(或路径)是将附加到根域的URL路径(请参阅this part of the routing docs)。
前缀将是添加到“资源”中包含的所有路由的模式(请参阅this part of the routing docs)。
例如......
fos_user_profile:
resource: "@FOSUserBundle/Resources/config/routing/profile.xml"
prefix: /profile
正在使用前缀@FOSUserBundle/Resources/config/routing/profile.xml
加载资源/profile
,这意味着包含的路由将以“prefix”为前缀
例如@FOSUserBundle/Resources/config/routing/profile.xml
有以下路线..
fos_user_profile_edit:
pattern: /edit
defaults:
_controller: FOSUserBundle:Profile:edit
但前缀为/profile
,它的完整路径(假设父路由文件中没有其他前缀)将位于/profile/edit
,而不仅仅是/edit
。