4

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 ?

Mat M
  • 1,786
  • 24
  • 30
JiDai
  • 136
  • 2
  • 3
  • 11
  • The tutorial says you have to use `\` instead of `:`. Do that and clear your cache. – greg0ire Nov 22 '11 at 21:59
  • @ greg0ire. I can't believe I lost 2 hours on that stupid error. Thanks for all. That's works... – JiDai Nov 22 '11 at 22:05
  • I tried some formatting in my comment but the backslash seems to escape the backtick, I meant "\" instead of `:` – greg0ire Nov 22 '11 at 22:08
  • I had a second error, namespace Gedmo was bad, I edited. So I thing the real error was on that line : `'Gedmo' => __DIR__.'/../vendor/doctrine-extensions/lib'`, But if I put `@Gedmo:Timestampable` instead of `@Gedmo\Timestampable`, it doesn't work either – JiDai Nov 22 '11 at 22:33

2 Answers2

1

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

greg0ire
  • 22,714
  • 16
  • 72
  • 101
0

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
semateos
  • 706
  • 6
  • 11