繁体   English   中英

Symfony路由关键字

[英]Symfony routes keywords

我对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:   /

模式(或路径)是将附加到您的根域的url路径(请参阅路由文档的这一部分 )。

前缀将是添加到“资源”中包含的所有路由的模式(请参阅路由文档的这一部分 )。

例如..

fos_user_profile:
    resource: "@FOSUserBundle/Resources/config/routing/profile.xml"
    prefix: /profile

正在使用前缀/profile加载资源@FOSUserBundle/Resources/config/routing/profile.xml ,这意味着所包含的路由将以该“前缀”为前缀

例如, @FOSUserBundle/Resources/config/routing/profile.xml中包含以下路由。

fos_user_profile_edit:
    pattern: /edit
    defaults:
        _controller: FOSUserBundle:Profile:edit

但使用前缀/profile其完整路径(假设父路由文件中没有其他前缀)将位于/profile/edit而不是/edit

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM