Download the PHP package fruitware/contact-bundle without Composer
On this page you can find all versions of the php package fruitware/contact-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download fruitware/contact-bundle
More information about fruitware/contact-bundle
Files in fruitware/contact-bundle
Package contact-bundle
Short Description Implementation of a contact form for Symfony2
License MIT
Homepage https://github.com/mremi/ContactBundle
Informations about the package contact-bundle
MremiContactBundle
This bundle provides a contact form in Symfony2.
License
This bundle is available under the MIT license.
Prerequisites
This version of the bundle requires Symfony 2.3+.
Translations
If you wish to use default texts provided in this bundle, you have to make sure you have translator enabled in your config.
For more information about translations, check the Symfony documentation.
Installation
Installation is a quick 6 step process:
- Download MremiContactBundle using composer
- Enable the Bundle
- Create your Contact class (optional)
- Configure the MremiContactBundle
- Import MremiContactBundle routing
- Update your database schema (optional)
Step 1: Download MremiContactBundle using composer
Add MremiContactBundle in your composer.json:
Now tell composer to download the bundle by running the command:
Composer will install the bundle to your project's vendor/mremi
directory.
Step 2: Enable the bundle
Enable the bundle in the kernel:
Step 3: Create your Contact class (optional)
The goal of this bundle is not to persist some Contact
class to a database,
but you can if you want just by setting the store_data
parameter to true
(default false
).
So if you don't need to do this, you can jump to the next step.
Your first job, then, is to create the Contact
class for your application.
This class can look and act however you want: add any properties or methods you
find useful. This is your Contact
class.
The bundle provides base classes which are already mapped for most fields to make it easier to create your entity. Here is how you use it:
- Extend the base
Contact
class from theEntity
folder - Map the
id
field. It must be protected as it is inherited from the parent class.
Note:
For now, only Doctrine ORM is handled by this bundle (any PR will be appreciated :) ).
Step 4: Configure the MremiContactBundle
The bundle comes with a sensible default configuration, which is listed below. However you have to configure at least a recipient address.
You can also configure your favorite captcha. You have to install it by yourself and configure it here. You can get one from these bundles:
Or even implement your own.
Step 5: Import MremiContactBundle routing
Now that you have activated and configured the bundle, all that is left to do is import the MremiContactBundle routing file.
By importing the routing file you will have ready access the contact form.
In YAML:
Or if you prefer XML:
Note:
In order to use the built-in email functionality, you must activate and configure the SwiftmailerBundle.
Step 6: Update your database schema (optional)
If you configured the data storage (step 3), you can now update your database schema.
If you want to first see the create table query:
Then you can run it:
You can now access to the contact form at http://example.com/app_dev.php/contact
!
Note:
If your are in debug mode (see your front controller), the HTML5 validation can be disabled by adding
?novalidate=1
to the URL.
Bootstrap
Bootstrap framework v3.0.2 is loaded and used in templates provided by this bundle.
Customization
Templating
If you want to customize some parts of this bundle (views for instance), read the Symfony documentation.
Events
The contact controller dispatches 3 events during the index action:
- ContactEvents::FORM_INITIALIZE occurs when the form is initialized
- ContactEvents::FORM_SUCCESS occurs when the form is submitted successfully
- ContactEvents::FORM_COMPLETED occurs after saving the contact in the contact form process
Each one allows you to customize the default workflow provided by this bundle.
Contribution
Any question or feedback? Open an issue and I will try to reply quickly.
A feature is missing here? Feel free to create a pull request to solve it!
I hope this has been useful and has helped you. If so, share it and recommend it! :)
All versions of contact-bundle with dependencies
symfony/framework-bundle Version ~2.1
symfony/form Version ~2.1
genemu/form-bundle Version 2.1.*