Question

Here is the problem : I don't succeed to install doctrine extensions with symphony 2, especially timestampable. I follow this tutorial

How I proceed :

I add this lines in deps file :

[gedmo-doctrine-extensions]
   git=http://github.com/l3pp4rd/DoctrineExtensions.git

[Stof-DoctrineExtensionsBundle]
   git=https://github.com/stof/StofDoctrineExtensionsBundle.git
   target=/bundles/Stof/DoctrineExtensionsBundle

Then I enter the line

./bin/vendors install --reinstall

All is fine.

Then I activate extensions in concerned files

# config.yml
stof_doctrine_extensions:
    default_locale: fr_FR
    orm:
        default:
            timestampable: true


# AppKernel.php    
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            [...]
            new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
            [...]
        );

# autoload.php
use Symfony\Component\ClassLoader\UniversalClassLoader;
use Doctrine\Common\Annotations\AnnotationRegistry;

$loader = new UniversalClassLoader();
$loader->registerNamespaces(array(
    'Gedmo'            => __DIR__.'/../vendor/gedmo-doctrine-extensions/lib',
    'Stof'             => __DIR__.'/../vendor/bundles', 
    [...]
    ));

At last, I add annotate my entity

/**
 * @var datetime $updatedAt
 *
 * @ORM\Column(name="updated_at", type="datetime")
 * @Gedmo:Timestampable(on="update")
 */
private $updatedAt;

But I have this error :

Fatal error: Class 'Gedmo\Timestampable\TimestampableListener' not found in /Symfony/app/cache/dev/appDevDebugProjectContainer.php on line 203

What do I do wrong ?

Was it helpful?

Solution

Using @Gedmo\Timestampable(on="update") and putting the right path when registering the namespace seems to solve the problem.

OTHER TIPS

For Symfony 2.0.x and Doctrine 2.1.x. projects you'll need to specify the compatible versions of the extensions in deps, this is what worked for me:

[DoctrineExtensions]
    git=https://github.com/l3pp4rd/DoctrineExtensions.git
    target=/gedmo-doctrine-extensions
    version=origin/doctrine2.1.x

[StofDoctrineExtensionsBundle]
    git=https://github.com/stof/StofDoctrineExtensionsBundle.git
    target=/bundles/Stof/DoctrineExtensionsBundle
    version=1.0.2
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top