douzhang6646 2016-07-08 17:44
浏览 90

在Symfony2.8中使用路由重定向

I'm trying to redirect with a route and I', following the official doc Symfony doc

But I've edited the config.yml file with the route field

imports:
    - { resource: parameters.yml }
    - { resource: security.yml }
    - { resource: services.yml }
    - { resource: "@UserBundle/Resources/config/services.yml" }

# Put parameters here that don't need to change on each machine where the app is deployed
# http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
    locale: en

framework:
    #esi:             ~
    #translator:      { fallbacks: ["%locale%"] }
    translator:      { fallbacks: [en] }
    secret:          "%secret%"
    router:
        resource: "%kernel.root_dir%/config/routing.yml"
        strict_requirements: ~
    form:            ~
    csrf_protection: ~
    validation:      { enable_annotations: true }
    #serializer:      { enable_annotations: true }
    templating:
        engines: ['twig']
    #default_locale:  "%locale%"
    default_locale:  es
    trusted_hosts:   ~
    trusted_proxies: ~
    session:
        # handler_id set to null will use default session handler from php.ini
        handler_id:  ~
    fragments:       ~
    http_method_override: true

# Twig Configuration
twig:
    debug:            "%kernel.debug%"
    strict_variables: "%kernel.debug%"

# Doctrine Configuration
doctrine:
    dbal:
        driver:   pdo_mysql
        host:     "%database_host%"
        port:     "%database_port%"
        dbname:   "%database_name%"
        user:     "%database_user%"
        password: "%database_password%"
        charset:  UTF8
        # if using pdo_sqlite as your database driver:
        #   1. add the path in parameters.yml
        #     e.g. database_path: "%kernel.root_dir%/data/data.db3"
        #   2. Uncomment database_path in parameters.yml.dist
        #   3. Uncomment next line:
        #     path:     "%database_path%"

    orm:
        auto_generate_proxy_classes: "%kernel.debug%"
        naming_strategy: doctrine.orm.naming_strategy.underscore
        auto_mapping: true

# Swiftmailer Configuration
swiftmailer:
    transport: "%mailer_transport%"
    host:      "%mailer_host%"
    username:  "%mailer_user%"
    password:  "%mailer_password%"
    spool:     { type: memory }

root:
    path: /crearUser
    defaults:
        _controller: UserBundle:Default:create
        route: crear
        permanent: true

But I get this error

InvalidArgumentException in YamlFileLoader.php line 399: There is no extension able to load the configuration for "root" (in /home/user/pruebasym/app/config/config.yml). Looked for namespace "root", found "framework", "security", "twig", "monolog", "swiftmailer", "doctrine", "sensio_framework_extra", "debug", "web_profiler", "sensio_distribution"

It looks like a missed somenthing but I haven't seen anything diferrent a the official doc

  • 写回答

1条回答 默认 最新

  • doupin1073 2016-07-08 18:37
    关注

    The identation level is not correct, If you want to set it in your config.yml, you must follow this indentation level :

    framework:
        router:
            root:
                path: /
                defaults:
                    _controller: FrameworkBundle:Redirect:urlRedirect
                    path: /app
                    permanent: true
    

    Or simpler, in your routing.yml (like the symfony doc suggests) :

    root:
        path: /
        defaults:
            _controller: FrameworkBundle:Redirect:urlRedirect
            path: /app
            permanent: true
    
    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置