Steps for a successful symfony living part 1

Suppose you have a mysql db somewhere. Lets make a very quick CRUD. As fast as possible ..


1) a glass of water,
2) a mysql db
3) the symfony sandbox

Here we go:

Step 1: edit config/databases.yml and use these as last lines:

dsn: mysql://<username>:<password>@<host>/<database_name> 

Step 2: edit config/propel.ini to set up propel properly:

propel.database            = mysql
propel.database.createUrl  = mysql://login:passwd@localhost
propel.database.url        = mysql://login:passwd@localhost/database
propel.mysql.tableType = InnoDB

setting up is done now lets get to the fun part

Step 3: we create the model from the mysql db, type at your cli:

symfony propel-build-schema

you should get some echo like:
Generating XML from Creole connection !
and at the end :
[propel-creole-transform] Propel – CreoleToXMLSchema finished
Total time: 1.1212 second
>> schema    putting /var/www/localhost/htdocs/estate/config/schema.yml
>> file-     /var/www/localhost/htdocs/estate/config/schema.xml
which indicates the success of the command. You now just created the schema of the db as a yml.
Step 4: now that we got the mysql model lets create the propel model by typing in your cli:
symfony propel-build-model
which will be used from now on throughout symfony.
You are actually done here. You can start building your applications now based on the work so far. So you should start with a backend and finish off with a frontend. 
Lets start the backend:
Step 1: type at the cli:
symfony init-app backend
to create the backend application
Step 2: type at the cli:
symfony propel-generate-crud backend images Image
to create the CRUD interface for the Image table and it will appear in the backend application as «images»
You are done for now. You can check out the CRUD at your address:
You can now go on and create simple CRUD interfaces for all your tables by this.
Final Step:
Drink the glass of water. You are done now.


Leave a Comment.