Home > Backend Development > PHP Tutorial > symfony命令行生成bundle后访问对应地址报404

symfony命令行生成bundle后访问对应地址报404

WBOY
Release: 2016-06-06 20:40:52
Original
1035 people have browsed it

<code>php app/console generate:bundle --namespace=Acme/HelloBundle --format=yml
</code>
Copy after login
Copy after login

这个语句一直回车生成代码之后 然后 访问/app_dev.php/hello/ 显示

No route found for "GET /hello/"

配置如下:

<code>   #Resources\config\routing.yml
    acme_hello_homepage:
        path:     /hello/{name}
        defaults: { _controller: AcmeHelloBundle:Default:index }

   #app\config\routing.yml
    acme_hello:
    resource: "@AcmeHelloBundle/Resources/config/routing.yml"
    prefix:   /
</code>
Copy after login
Copy after login

symfony 版本为2.5.6
本人对于这个框架只限于看了官方的文档,我自己研究了会不知道为啥还是不行
望哪位大大 能提点下~~

回复内容:

<code>php app/console generate:bundle --namespace=Acme/HelloBundle --format=yml
</code>
Copy after login
Copy after login

这个语句一直回车生成代码之后 然后 访问/app_dev.php/hello/ 显示

No route found for "GET /hello/"

配置如下:

<code>   #Resources\config\routing.yml
    acme_hello_homepage:
        path:     /hello/{name}
        defaults: { _controller: AcmeHelloBundle:Default:index }

   #app\config\routing.yml
    acme_hello:
    resource: "@AcmeHelloBundle/Resources/config/routing.yml"
    prefix:   /
</code>
Copy after login
Copy after login

symfony 版本为2.5.6
本人对于这个框架只限于看了官方的文档,我自己研究了会不知道为啥还是不行
望哪位大大 能提点下~~

你试过清除cache了吗?
清除命令是:

<code>app/console cache:clear --env=prod
app/console cache:clear --env=dev
</code>
Copy after login

同样的,你需要检查route是否配置正确

<code>app/console router:debug
</code>
Copy after login

路由是 /hello/{name}
你访问 /hello/mot 就有了

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template