Symfony2 缓存和路由生成
这是我第一次尝试使用 Symfony2 创建一些东西。
我有我的数据库,我想从它自动生成模型。所以我运行
php app/console doctrine:mapping:import MYBundle php
并
php app/console doctrine:generate:entities MYBundle
确定,我的实体现在已创建。
然后我想创建基本的增删改查操作,所以我运行
php app/console generate:doctrine:crud
Which is Should 为所选模型创建控制器、视图和路由表。
问题是路由表没有生成,所以如果我导航到 /posts,并且我的 index.html.twig 包含
path('users_show', { 'id': entity.id }) }}
我的服务器发送 500 错误。
Symfony 甚至没有捕获该错误并向我显示漂亮的格式化异常。
此外,如果我修改我的index.html.twig,它将保持缓存状态,直到我不 rm -R /app/cache/dev 文件夹。
有没有办法禁用缓存?
[编辑]
我的routing_dev.yml
_welcome:
pattern: /
defaults: { _controller: OREBundle:Default:index }
_assetic:
resource: .
type: assetic
_wdt:
resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml"
prefix: /_wdt
_profiler:
resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml"
prefix: /_profiler
_configurator:
resource: "@SensioDistributionBundle/Resources/config/routing/webconfigurator.xml"
prefix: /_configurator
_main:
resource: routing.yml
和我的routing.yml
_welcome:
pattern: /
defaults: { _controller: OREBundle:Default:index }
_users:
pattern: /users
defaults: { _controller: OREBundle:Users:index}
this is my first attempt to create something with Symfony2.
I have my database, and I wanted to generate models from it automatically. So I run
php app/console doctrine:mapping:import MYBundle php
and
php app/console doctrine:generate:entities MYBundle
Ok, my entities are now created.
Then I wanted to create basic crud operations, so i run
php app/console generate:doctrine:crud
Which is supposed to create Controllers,Views and Routing table for the selected models.
The problem is that the routing table isn't generated, so if i navigate to, let's say, /posts, and my index.html.twig contains
path('users_show', { 'id': entity.id }) }}
My server send a 500 Error.
Symfony doesn't even catch that error and show me the nice formatted exception.
Furthermore if i modify my index.html.twig, it will remain cached until i don't rm -R the /app/cache/dev folder.
Is there a way to disable caching?
[EDIT]
my routing_dev.yml
_welcome:
pattern: /
defaults: { _controller: OREBundle:Default:index }
_assetic:
resource: .
type: assetic
_wdt:
resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml"
prefix: /_wdt
_profiler:
resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml"
prefix: /_profiler
_configurator:
resource: "@SensioDistributionBundle/Resources/config/routing/webconfigurator.xml"
prefix: /_configurator
_main:
resource: routing.yml
and my routing.yml
_welcome:
pattern: /
defaults: { _controller: OREBundle:Default:index }
_users:
pattern: /users
defaults: { _controller: OREBundle:Users:index}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我猜您从未使用
--with-write
选项运行命令。来自 symfony2 文档:您可以尝试使用此命令再次运行
generate-entities
选项。I'm guessing that you never ran your command with the
--with-write
option. From the symfony2 docs:You can try running your
generate-entities
again with this option.