Installing Doctrine extensions in a Symfony 2 project causes a fatal error

Here's the problem: I was unable to install doctrine extensions with symphony 2, especially a temporary one. I follow this tutorial

As I continue:

I add these lines to the 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 

Everything is good.

Then I activate the extensions in the corresponding 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', [...] )); 

Finally, I add an annotation of my essence

 /** * @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' was not found in /Symfony/app/cache/dev/appDevDebugProjectContainer.php on line 203

What am I doing wrong?

+4
source share
2 answers

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

+1
source

For Symfony 2.0.x and Doctrine 2.1.x. projects you will need to specify compatible versions of extensions in folders, 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 
0
source

Source: https://habr.com/ru/post/1382597/


All Articles