After doing several Google searches and asking for help on some IRC forums, it became clear that very few people knew much about getting Symfony to work with PostgreSQL. Not surprising since almost all PHP developers use MySQL. Turns out, it is not as bad as it sounds to get Symfony up and running with PostgreSQL quickly.
Step 1: Install PostgreSQL. Quick instructions for this can be found on PostgreSQL's own website: http://www.postgresql.org/docs/8.4/interactive/install-short.html. The only thing I would change about this is adding the --with-openssl option when you run the configure script before compiling.
Step 2: Start your Symfony project. This is also pretty straight forward, the instructions for this are here: http://www.symfony-project.org/jobeet/1_4/Doctrine/en/01
Step 3: Download the Symfony plugin for PostgreSQL.
php ./symfony plugin:install sfPostgresDoctrinePlugin
Step 4: Publish the plugin.
php ./symfony plugin:publish-config
Step 5: Alter the config/ProjectConfiguration.class.php file to get the enablePlugins function to accept an array.
class ProjectConfiguration extends sfProjectConfiguration
{
public function setup()
{
$this->enablePlugins(array(
'sfDoctrinePlugin',
'sfPostgresDoctrinePlugin'));
}
}
Step 6: Create the plpgsql language. As the postgresql user run the command:
createlang plpgsql [databasename]
And there you have it! You should now be able to operate Symfony with PostgreSQL just like you did with MySQL. Enjoy!
This is a nice article..
ReplyDeleteIts very easy to understand ..
And this article is using to learn something about it..
c#, dot.net, php tutorial
Thanks a lot..!
What postgre and php version do you use? I have problems installing postgre with Symfony :(
ReplyDeleteWhen this article was written, it was using the latest versions of Symfony and Postgres. What kind of problems are you having?
ReplyDeleteHi Matthew,
ReplyDeleteWhen I try to insert the generated sql scripts of sfPostgresDoctrinePlugin is results to an error.
Can you give me some more details Mark? What operating system? What version of Symfony? What version of PHP? What version of PostgreSQL?
ReplyDeleteWonderful blog & good post.Its really helpful for me, awaiting for more new post. Keep Blogging!
ReplyDeleteSymfony Development