eminetto / silex-sample

silex-sample
39 stars 18 forks source link

Database schema #3

Closed victorferreira closed 6 years ago

victorferreira commented 11 years ago

I was studding Silex at Code Squad and I decide run this example on my own computer. I can't find the database schema at this project. When I run the app, it returns a error 500. May You give me the database schema?

Thanks!

luismilanese commented 10 years ago

Hi Victor, I have not yet seen the Silex course at Code Squad, which I intend to do in a near future. However, I use Symfony at work so I can guess what's wrong.

Even though he has not provided any database, the ORM has the ability to mount a database from the entities. If you go to src/Coderockr/Model/, you can see there is an entity called User.php. I am not getting into much details, but this file, in a way, represent what the User table should be, right? You see it describes the field names, field types and all.

With that in hand, you can go to the root dir of your directory and run:

$ php bin/doctrine orm:validate-schema

That will compare the current state of your database with your entities. In this case, it will fail. Because you have entities which are not represented in your database. To fix that, you can run the following command to CREATE your schema:

$ php bin/doctrine orm:schema-tool:create

This command will generate the database. For the next entities you create, you can run the following command to UPDATE your schema that has been created when you run the command above:

$ php bin/doctrine orm:schema-tool:update

Hope that helps. Elton can provide us with further details.