Symfony2 and me – let’s be friends – Part 3

So far, I have a base project with Propel as my ORM, connected to an exisitng DB, re-engineered the schema and could start to do something with it, now.

My next goal is to create a user authentication. After a lot of thoughts on if/yes/no I decided to use the FOSUserBundle – hoping it will provide some features I could use and still would integrate if I want to use OPTIONAL ALTERNATIVE Facebook and Twitter login…

Step 7: Add FOSUserBundle

I’m following the steps in the docs and add the line to composer and do an update. It suggests Doctrine, BTW, but I ignore that, thank you. But, for Propel, it says I need to move my schema.xml to app/Resources/FOSUserBundle/config/propel/schema.xml. Well, my schema already contains a User (which is unused atm) that contains an id – so it might work?!
Now did the configurationa steps of the doc (including installation of the typehintable behaviour) and reran my propel-build… SUCCESSFULLY, so I really could see a page on /app_dev.php/login. Impressive!

Well, no, it did not… First: I missed that I should copy the schema.xml of the bundle to “app/……”. Second: Looks like I got mislead with my expectations about schema.xml, where to put it, and where Models will be generated… Can I have FOSBundle generate it’s User class into my Bundles folders? How can I create relations between the User Class of FOSBundle and my app?

Questions to be answered later, I hope

Symfony2 and me – let’s be friends – Part 2

I have a running, blank symfony2 project now, with Propel instead of Doctrine – but no DB or bundle yet

Step 5: Gimme a bundle

I know there is this bundle generator, so let’s see it:
app/console generate:bundle
I chose my namespace and hit some [Return]s – and I’m good to go – WOW, yes it’s there! Not much in there, yet, but I’ll check later.

Step 6: The database

Nice so far! Now I’d like to connect to my exisitng database and use Propel’s magic database reverse-engineering
Thanks to composer I don’t have to deal with namespace and prefix configurations, so I can go to the db- connection settings directly
So I add the basic propel config with parameters (http://www.propelorm.org/cookbook/symfony2/working-with-symfony2.html) to my app/config.yml; then I need to set the paramters in parameters.yml
No, how can I check if the connection works? Why not run the reverse-engineering process directly?
app/console propel:reverse “No generated files” Hmmm, my connection might not work – but there is no error 🙁
SO, I manually check the permissions again (quickly dumping an adminer into the web dir) and YES, there is a problem with the permissions. SO I fix this, then run app/console propel:reverse again – and I have a file!!!

Step 7: Adjust the db schema

For the time being, the schema looks quite ok, so I’ll just move it from the generated-schemas folder to a more appropriate destination, being the Resources/config folder of my bundle.
To run propel:build now, I only need to add a namespace=”my\bundle\namespace” to the database tag of the xml, and it generates my models!

Enough preparational stuff, more coding next days!

Symfony2 and me – let’s be friends – Part 1

My journey, starting a rewrite of an exisitng project from scratch with Symfony2

Step 1: Get the framework:

composer.phar create-project symfony/framework-standard-edition path
After giving my VM some more RAM (512MB wasn’t enough) it succeeded.

Step 2: Get rid of Doctrine and grab Propel

So I edit the composer.json file and delete the two doctrine lines (if someone other lib needs doctrine/common for annotations, they will solve the dependency, right?
Then add "propel/propel-bundle": "1.1.*" to the file instead, as stated on http://www.propelorm.org/cookbook/symfony2/working-with-symfony2.html
Then I run “composer.phar update” and it updates my monolog, removes doctrine and installs propel, its bundle and phing.
After that, however, the symfony cache update fails – if course, I removed Doctrine which is configured somewhere in the the Kernel.

So I remove the Doctrine line from app/AppKernel.php and all doctrine stuff from app/config/config.yml – and HOORAY, my app/console is green again

Step 3: Does it work?

My webserver is already configured to check for an app.php in the web subfolder, so it works – but first I’ll add my IP to app_dev.php so I can see all the debug beauty of Symfony2
Checking the Debug toolbar I notice Propel is missing – of course, I need to add it to the kernel where I kicked out Doctrine
So I add new Propel\PropelBundle\PropelBundle(), to app/AppKernel.php where I commented Doctrine befor, and app/console knows some good old Propel commands now.

Step 4: Freeze this into git

This is a good start, so I want to get this status into git. I’m surprised to see that there IS already a lot of git-information in the directory, being the symfony2 history.
Quick fix, rm -rf .git and git init again, here I come. On the plus side, I already have a nice .gitignore 😀
git add .; git commit -m “Fresh start”