Adding A New Behavior In Symfony2

Propel provides a lot of behaviors but there are also third-party behaviors provided by the community.

In order to get these behaviors working in a Symfony2 application with Propel, you need to register them, here is how you should do.

The first step is to get the code. If the behavior is available on a Git repository, like GitHub for instance, then you'll be able to add it to your deps file. Assuming you want to use the GeocodableBehavior, you'll write:

[GeocodableBehavior]
    git=http://github.com/willdurand/GeocodableBehavior.git
    target=/willdurand/propel-geocodable-behavior

If you are using Git submodules, then run:

git submodule add http://github.com/willdurand/GeocodableBehavior.git vendor/willdurand/propel-geocodable-behavior

If you are using Composer, then just require the behavior in your composer.json:

{
    "require": {
        // ...
        "willdurand/propel-geocodable-behavior": "dev-master"
    }
}

And run, php composer.php update.

Tip
If there is no available Git repository for a behavior, just copy it to vendor/propel-thebehavior-behavior. It's up to you to version it or not.

You're done!

Found a typo ? Something is wrong in this documentation ? Just fork and edit it !