This version of the bundle requires Symfony 2.1+.
Installation process in 5 steps:
- Download AmenophisSocialBundle using composer
- Enable the Bundle
- Create your Social class
- Configure the AmenophisSocialBundle
- Update your database schema
Add AmenophisSocialBundle in your composer.json:
{
"require": {
"amenophis/social-bundle": "dev-master"
}
}
Now tell composer to download the bundle by running the command:
$ php composer.phar update amenophis/social-bundle
Composer will install the bundle to your project's vendor/amenophis
directory.
Enable the bundle in the kernel:
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Amenophis\Bundle\SocialBundle\AmenophisSocialBundle(),
);
}
If you're persisting social data via the Doctrine ORM, then your Social
class
should live in the Entity
namespace of your bundle and look like this to
start:
<?php
namespace Acme\Bundle\CoreBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Amenophis\Bundle\SocialBundle\Model\Social as BaseSocial;
/**
* Social
*
* @ORM\Table(name="acme_social",
* uniqueConstraints={
* @ORM\UniqueConstraint(
* name="unique_by_type",
* columns={"class_name", "type", "item_id", "user_id"}
* )
* }
* )
* @ORM\Entity()
* @UniqueEntity(fields={"class_name", "type", "item_id", "user_id"}, message="amenophis.social.unique")
*/
class Social extends BaseSocial
{
// ...
}
Add the following configuration to your config.yml
file.
# app/config/config.yml
amenophis_social:
classes:
social:
entity: Acme\Bundle\CoreBundle\Entity\Social
Now that the bundle is configured, the last thing you need to do is update your
database schema because you have added a new entity, the Social
class which you
created in Step 3.
For ORM run the following command.
$ php app/console doctrine:schema:update --force
All is now OK to start using the bundle !
The following documents are available: