Event-based contact bundle

Installs: 3 797

Dependents: 0

Stars: 6

Watchers: 4

Forks: 7

Open Issues: 3

Language: PHP

1.0.1 2014-01-13 13:04 UTC


Build Status

An event-based Symfony2 Contact Bundle.


Install the bundle via composer

 $ composer require frequence-web/contact-bundle:1.0.*

Add the bundle to your AppKernel class

    public function registerBundles()
        return array(
            // ... Your bundles
            new \FrequenceWeb\Bundle\ContactBundle\FrequenceWebContactBundle(),


This bundle provides some configuration options :

    send_mails: true                # True to use the bundle EmailListener that send emails when contact form is submited
    to:         null                # The contact mail recipient
    from:       null                # The contact mail sender
    subject: # The contact mail subject translation key


If you want to use the default bundle urls, just import the routing file in your application routing:

        resource: '@FrequenceWebContactBundle/Resources/config/routing.xml'

This will create 2 routes, with the same URL (/contact.html), one for displaying the contact form (GET), the other to submit data (POST)

Creating Listener

If you want to make a more featured mail listener, or any other listener, you have to define your own. The dispatched event on success contact form submit is contact.submit, and receive a FrequenceWeb\Bundle\ContactBundle\EventDispatcher\Event\MessageSubmitEvent.

If you need an example, juste have a look to FrequenceWeb\Bundle\ContactBundle\EventDispatcher\Listener\EmailContactListener.


If you need more datas that the few ones provided by the Contact class and the ContactType form type, just override the frequence_web_contact.type.class and frequence_web_contact.model.class configuration parameters, they are used to instantiate services and can be extended without any limit.