Symfony 2:未使用FosUserBundle路由加载CSS和JS(错误链接)

时间:2015-05-12 14:51:20

标签: symfony templates routing fosuserbundle

*你好,我来这里是因为我从现在开始找到0个解决方案...... 我开始使用FosUserBundle并享受功能!但是因为有一个但是......:p

当我尝试进入登录页面时,没关系: app_dev.php / login

现在我尝试所有其他链接: / profile - / register - / resetting 没有人可以加载css和js ......

所以我搜索为什么,我发现了这个:

从/登录我需要 ../ css / images ../ js / vendor 作为示例

来自/注册或我需要做的其他两个链接 ../../ css / images ../../ js / vendor

为什么会这样改变?为什么Symfony无法从同一路径加载css和js?这很烦人,因为我无法在fosuserbundle上看到和修改模板。

我只修改了routing.yml和security.yml:

# routing.yml
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

然后安全

# app/config/security.yml
security:
encoders:
    FOS\UserBundle\Model\UserInterface: sha512

role_hierarchy:
    ROLE_ADMIN:       ROLE_USER
    ROLE_SUPER_ADMIN: ROLE_ADMIN

providers:
    fos_userbundle:
        id: fos_user.user_provider.username

firewalls:
    dev:
        pattern:  ^/(_(profiler|wdt)|css|images|js)/
        security: false
    main:
        pattern:          ^/
        form_login:
            check_path:   /login_check
            login_path:   /login
            provider:     fos_userbundle
        logout:
            path:         /logout
            target:       /
          # provider: fos_userbundle
          # csrf_provider: form.csrf_provider
        remember_me:
            key:         %secret%
            lifetime:    300000000
            path: /
            domain :     ~
        anonymous:        true

access_control:
    - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/admin/, role: ROLE_ADMIN }

如果有人有想法或同样的问题;)提前致谢,祝你有愉快的一天!!

0 个答案:

没有答案