views:

56

answers:

1

Hello,

I'm completely new with Symfony and Doctrine. I have generated a project with a the Doctrine ORM, my database schema is fully well generated. Now I just want to create basic services (in simple .php pages) that do some actions according to parameters in a HTTP POST request.

I tried to create an app through the generate:app command but it seems to be a really ugly way... I just need a basic .php page where I can use my doctrine objects and interact with my database easly. What is the easiest way to do that (can I do that with some basic require_once or I need to generate something with symfony, like a module ?) ?

Thank you!

+4  A: 

I think symfony might not be for you. There is a 'symfony-way' of doing things. Part of that is the MVC seperation of logic.

A simple page would be:

$ ./symfony generate:project yourprojectname
$ ./symfony configure:database "mysql:host=localhost;dbname=yourdbname" root yourpassword
$ ./symfony generate:app frontend
$ ./symfony generate:module frontend yourmodule

Ok, now you have a module. Go to localhost/web/frontend_dev.php/module and you will see that you have setup a basic module and a congratulations message.

Read up on the URI-routing of symfony. localhost/web/frontend_dev.php/module/action/param/value, that's the basic default routing.

So it will call the action in your module and pass the parameter's value.

Do anything you want with it.

That said, you will have to read up on how symfony works. The framework can help you with a lot of things, if you know how it works. If you don't it will be more likely slowing you down.

Start here: http://www.symfony-project.org/get/pdf/jobeet-1.4-doctrine-en.pdf it will walk you through from beginning to end of a rather extensive project. Some of the things might seem a bit clumsy, but that is because in the process they WILL show you most everything that framework can do.

tilman
Thank you, I noticed that symfony was maybe not for me after all... I just wanted to generate Doctrine classes from YAML files and I didn't find anything else than using Sympfony. So really, I need to access Doctrine classes from a custom page, I can't do that easily with Symfony?
MartinMoizard
Why don't you use straight up Doctrine, without Symfony? http://www.doctrine-project.org/ and they have a starters' tutorial as well: http://www.doctrine-project.org/projects/orm/1.2/docs/cookbook/my-first-project/en
tilman
I don't know what went through my mind but I was sure that I needed Symfony to generate my Doctrine classes with YAML files... Never mind! Thank you for your quick answers :) !
MartinMoizard