Init A Symfony Project With Propel As Default ORM - The Git Way
Since this summer (2011) Propel ORM has a new symfony integration plugin sfPropelORMPlugin replacing the old one sfPropel15Plugin.
The old sfPropel15Plugin caused some confusion at each new Propel's version.
Now sfPropelORMPlugin will always integrate the last Propel's version to Symfony 1.4.
You'll learn how to set up a new symfony 1.4 project with all necessary libraries as git submodules.
First, set up a new project:
mkdir propel_project
cd propel_project
git initInstall symfony 1.4 as a git submodule:
git submodule add git://github.com/symfony/symfony1.git lib/vendor/symfonyGenerate a symfony project:
php lib/vendor/symfony/data/bin/symfony generate:project propelAdd the sfPropelORMPlugin plugin:
git submodule add git://github.com/propelorm/sfPropelORMPlugin plugins/sfPropelORMPluginGet Propel and Phing bundled with the plugin:
cd plugins/sfPropelORMPlugin
git submodule update --initYou should add a .gitignore file with the following content:
config/databases.yml
cache/*
log/*
data/sql/*
lib/filter/base/*
lib/form/base/*
lib/model/map/*
lib/model/om/*Now, enable sfPropelORMPlugin in config/ProjectConfiguration.class.php:
<?php
class ProjectConfiguration extends sfProjectConfiguration
{
public function setup()
{
$this->enablePlugins('sfPropelORMPlugin');
}
}Publish assets:
php symfony plugin:publish-assetsCopy the propel.ini default file in your project:
cp plugins/sfPropelORMPlugin/config/skeleton/config/propel.ini config/propel.iniVerify behaviors lines look like:
// config/propel.ini
propel.behavior.symfony.class = plugins.sfPropelORMPlugin.lib.behavior.SfPropelBehaviorSymfony
propel.behavior.symfony_i18n.class = plugins.sfPropelORMPlugin.lib.behavior.SfPropelBehaviorI18n
propel.behavior.symfony_i18n_translation.class = plugins.sfPropelORMPlugin.lib.behavior.SfPropelBehaviorI18nTranslation
propel.behavior.symfony_behaviors.class = plugins.sfPropelORMPlugin.lib.behavior.SfPropelBehaviorSymfonyBehaviors
propel.behavior.symfony_timestampable.class = plugins.sfPropelORMPlugin.lib.behavior.SfPropelBehaviorTimestampableAdapt your databases.yml or copy the model in your project:
cp plugins/sfPropelORMPlugin/config/skeleton/config/databases.yml config/databases.ymlIt has to look like this:
# You can find more information about this file on the symfony website:
# http://www.symfony-project.org/reference/1_4/en/07-Databases
dev:
propel:
param:
classname: DebugPDO
debug:
realmemoryusage: true
details:
time: { enabled: true }
slow: { enabled: true, threshold: 0.1 }
mem: { enabled: true }
mempeak: { enabled: true }
memdelta: { enabled: true }
test:
propel:
param:
classname: DebugPDO
all:
propel:
class: sfPropelDatabase
param:
classname: PropelPDO
dsn: mysql:dbname=test;host=localhost
username: root
password:
encoding: utf8
persistent: true
pooling: trueWarning
If your PHP version is under 5.3.6 you won't be allowed to set theencodingparameter due to a security issue in PHP.
You're now ready for writing a schema.xml and building your project.
Found a typo ? Something is wrong in this documentation ? Just fork and edit it !