0
votes

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}
1
are you hitting /app_dev.php? also, post the contents of your routing.yml and routing_dev.yml - JamesHalsall
was hitting /app.php. now it shows the formatted exception from symfony saying that "Route "users_show" does not exist." i'll edit my post to add the routing.yml - hjeldin
what happens when you try path('users', { 'id': entity.id, 'action': 'show' }) }} - JamesHalsall
the page renders, but i get this url : /app_dev.php/users?id=1&action=edit - hjeldin
Why do you name the route _users instead of users ? - Thomas Decaux

1 Answers

0
votes

I'm guessing that you never ran your command with the --with-write option. From the symfony2 docs:

--with-write: (no) [values: yes|no] Whether or not to generate the new, create, edit, update and delete actions

You can try running your generate-entities again with this option.