Problème avec StofDoctrineExtensionsBundle

Par dadidee, il y a 11 ans


Hello tous,

En ce moment, je suis en apprentissage de Symfony, et je me trouve confrontée au même problème pour la seconde fois (à force de tester différentes solutions chinées sur le net, le problème de base était de moins en moins accessible que j'ai préféré reprendre mon projet en amont.)
Je précise aussi que je n'ai eu aucun problème pour installer 2 autres bundles juste avant.

Je me retrouve donc à l'étape de l'installation du bundle StofDoctrineExtensions via composer :

Et bim !

Fatal error: Class 'Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle' not found in C:\wamp\www\portfolio\app\AppKernel.php on line 23 Call Stack: 0.0002 234416 1. {main}() C:\wamp\www\portfolio\app\console:0 0.0229 3598192 2. Symfony\Component\Console\Application->run() C:\wamp\www\portfolio\app\console:27 0.0263 3830712 3. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() C:\wamp\www\portfolio\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:126 0.0263 3830936 4. Symfony\Component\HttpKernel\Kernel->boot() C:\wamp\www\portfolio\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Console\Application.php:70 0.0263 3831216 5. Symfony\Component\HttpKernel\Kernel->initializeBundles() C:\wamp\www\portfolio\app\bootstrap.php.cache:2342 0.0263 3831656 6. AppKernel->registerBundles() C:\wamp\www\portfolio\app\bootstrap.php.cache:2512

Bon, je teste voir si l'activation d'un extension modifiera la donne, mais ... nada.

Et forcément, l'erreur sur la page du site :

ClassNotFoundException in AppKernel.php line 23:<br>Attempted to load class "StofDoctrineExtensionsBundle" from namespace "Stof\DoctrineExtensionsBundle". Did you forget a "use" statement for another namespace?

Je pensais que la solution devait se trouver dans la pile d'appel du terminal, je suis donc allée voir la ligne indiquée par le 6e appel :

foreach ($this->registerBundles() as $bundle){...}

Je me dis que le problème doit être dans cette boucle, mais le fichier n'étant pas indenté et ayant peu d’expérience dans le domaine, j'ai hum ...
un peu rien compris.

Sur le net, j'ai lu que pour certains, composer n'avait pas tout installé et qu'il y avait donc les répertoires vendor/stof/doctrine-extensions-bundle et/ou vendor/gedmo/doctrine-extensions vides, mais ce n'est pas mon cas.

Pour d'autres, le problème pouvait venir de l'activation de la ligne extension=php_openssl.dll sur le php.ini de wamp, mais apparemment c'est surtout lié à une erreur de RuntimeException que je n'ai pas. (Perso, cette ligne est sans points virgules)

J'ai trouvé sinon que le problème pouvait venir de l'autoload, même si normalement avec la version Symfony 2.6.3 que j'utilise, je ne devrais pas mettre mon nez dedans (et que c'est dans un sous-dossier de /vendor, non ?). J'ouvre donc autoload_namespaces.php, et je ne sais pas si je devrais normalement trouver au moins une ligne sur une quelconque chemin vers Stof, en tout cas j'ai "seulement" ça :

<?php // autoload_namespaces.php @generated by Composer $vendorDir = dirname(dirname(__FILE__)); $baseDir = dirname($vendorDir); return array( 'Twig_Extensions_' => array($vendorDir . '/twig/extensions/lib'), 'Twig_' => array($vendorDir . '/twig/twig/lib'), 'Symfony\\' => array($vendorDir . '/symfony/symfony/src'), 'SymfonyStandard' => array($baseDir . '/app'), 'Sensio\\Bundle\\GeneratorBundle' => array($vendorDir . '/sensio/generator-bundle'), 'Sensio\\Bundle\\FrameworkExtraBundle' => array($vendorDir . '/sensio/framework-extra-bundle'), 'Sensio\\Bundle\\DistributionBundle' => array($vendorDir . '/sensio/distribution-bundle'), 'SensioLabs\\Security' => array($vendorDir . '/sensiolabs/security-checker'), 'Psr\\Log\\' => array($vendorDir . '/psr/log'), 'Nelmio\\ApiDocBundle' => array($vendorDir . '/nelmio/api-doc-bundle'), 'Negotiation' => array($vendorDir . '/willdurand/negotiation/src'), 'Michelf' => array($vendorDir . '/michelf/php-markdown'), 'Knp\\Menu\\' => array($vendorDir . '/knplabs/knp-menu/src'), 'Knp\\Bundle\\MenuBundle' => array($vendorDir . '/knplabs/knp-menu-bundle'), 'JsonpCallbackValidator' => array($vendorDir . '/willdurand/jsonp-callback-validator/src'), 'Incenteev\\ParameterHandler' => array($vendorDir . '/incenteev/composer-parameter-handler'), 'Gedmo\\' => array($vendorDir . '/gedmo/doctrine-extensions/lib'), //'FOS\\UserBundle' => array($vendorDir . '/friendsofsymfony/user-bundle'), //'FOS\\RestBundle' => array($vendorDir . '/friendsofsymfony/rest-bundle'), 'Exporter' => array($vendorDir . '/sonata-project/exporter/lib'), 'Doctrine\\ORM\\' => array($vendorDir . '/doctrine/orm/lib'), 'Doctrine\\DBAL\\' => array($vendorDir . '/doctrine/dbal/lib'), 'Doctrine\\Common\\Lexer\\' => array($vendorDir . '/doctrine/lexer/lib'), 'Doctrine\\Common\\Inflector\\' => array($vendorDir . '/doctrine/inflector/lib'), 'Doctrine\\Common\\DataFixtures' => array($vendorDir . '/doctrine/data-fixtures/lib'), 'Doctrine\\Common\\Collections\\' => array($vendorDir . '/doctrine/collections/lib'), 'Doctrine\\Common\\Cache\\' => array($vendorDir . '/doctrine/cache/lib'), 'Doctrine\\Common\\Annotations\\' => array($vendorDir . '/doctrine/annotations/lib'), 'Doctrine\\Common\\' => array($vendorDir . '/doctrine/common/lib'), 'Doctrine\\Bundle\\FixturesBundle' => array($vendorDir . '/doctrine/doctrine-fixtures-bundle'), 'Doctrine\\Bundle\\DoctrineCacheBundle' => array($vendorDir . '/doctrine/doctrine-cache-bundle'), 'Assetic' => array($vendorDir . '/kriswallsmith/assetic/src'), '' => array($baseDir . '/src'), );

Voilà en gros où j'en suis, donc si quelqu'un comprend la situation et entr'aperçoit une solution, ce serait super green comme dirait l'autre.

Et moi je pourrais faire la danse du bonheur.

Amicalement,

7 réponses

Blondin69, il y a 11 ans

Salut tu peux montrer ton appKernel.php ?

dadidee, il y a 11 ans

Bien sûr :

class AppKernel extends Kernel { public function registerBundles() { $bundles = array( new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), new Symfony\Bundle\SecurityBundle\SecurityBundle(), new Symfony\Bundle\TwigBundle\TwigBundle(), new Symfony\Bundle\MonologBundle\MonologBundle(), new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(), new Symfony\Bundle\AsseticBundle\AsseticBundle(), new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(), new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(), new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(), new AppBundle\AppBundle(), new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(), );
Blondin69, il y a 11 ans

Est-ce qu tu as configuré le mapping ? Je sais pas si ça peut venir de la mais on sais jamais.

# app/config/config.yml doctrine: orm: entity_managers: default: mappings: gedmo_translatable: type: annotation prefix: Gedmo\Translatable\Entity dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translatable/Entity" alias: GedmoTranslatable # this one is optional and will default to the name set for the mapping is_bundle: false gedmo_translator: type: annotation prefix: Gedmo\Translator\Entity dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translator/Entity" alias: GedmoTranslator # this one is optional and will default to the name set for the mapping is_bundle: false gedmo_loggable: type: annotation prefix: Gedmo\Loggable\Entity dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Loggable/Entity" alias: GedmoLoggable # this one is optional and will default to the name set for the mapping is_bundle: false gedmo_tree: type: annotation prefix: Gedmo\Tree\Entity dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Entity" alias: GedmoTree # this one is optional and will default to the name set for the mapping is_bundle: false
dadidee, il y a 11 ans

Ce mapping sert-il pour activer les extensions ? Car je n'avais aucun de ces lignes dans mon config.yml
Je les ai rajoutées mais l'erreur est toujours là.

As tu réussi à installer ce bundle ? Si c'est le cas, pourrais tu me dire si ton autoload_namespace.php est différent du mien ?

Merci à toi !

Blondin69, il y a 11 ans

de rien! bon courage pour la suite

Blondin69, il y a 11 ans

Oui j'ai réussi a l'installer, je viens de me rendre compte qu'il c'est installé aussi sur mon dernier projet avec sylius, et j'ai bien une ligne dans l'autoload:

'Stof\\DoctrineExtensionsBundle' => array($vendorDir . '/stof/doctrine-extensions-bundle'),

Essaie de supprimer ton dossier vendor et de relancer composer update...

Sinon t'es sur quel version de symfony ?

dadidee, il y a 11 ans

Je suis sur la v2.6.3

Sinon j'ai rajouté ta ligne dans mon autoload_namespaces.php et tout fonctionne ! :) Ô joie !

Ensuite j'ai supprimer le dossier vendor et ai fait un update de composer. Il m'a recréé le dossier mais mal, j'ai une erreur SensioGeneratorBundle, pitêtre la version à changer, je vais vérifier ça ...

[Composer\DependencyResolver\SolverProblemsException] Problem 1 - The requested package sensio/generator-bundle 2.3.* could not be found. Potential causes: - A typo in the package name - The package is not available in a stable-enough version according to your m see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further comm

Du coup mon dossier vendor/composer ne contenait plus que le fichier installed.json et il devait sûrement manquer d'autres fichiers car j'avais erreur sur erreur.

Mais ranafout, j'avais sauvegardé mon projet avant d'y apporter la grosse modif, donc grâce à toi le problème est résolu. Merci beaucoup ! :)