How to setup Symfony-cmf with Sonata Admin on existing Symfony 2 project?-Collection of common programming errors
CharlesI have been trying to setup Sonata Admin with Symfony-CMF for my project, and i have some errors when i trying to add menu item.
How to fix this?
Error:
The class ‘Symfony\Cmf\Bundle\MenuBundle\Document\MenuItem’ was not found in the chain configured namespaces Doctrine\ODM\PHPCR\Document
Logs:
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelRequest". DEBUG - Notified event "kernel.request" to listener "Symfony\Bundle\FrameworkBundle\EventListener\SessionListener::onKernelRequest". DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\RouterListener::onKernelRequest". DEBUG - SET NAMES UTF8 DEBUG - SELECT t0.id AS id1, t0.name AS name2, t0.billing_address AS billing_address3, t0.contact_name AS contact_name4, t0.contact_email_address AS contact_email_address5, t0.contact_phone_number AS contact_phone_number6 FROM client t0 DEBUG - SELECT t0.id AS id1, t0.name AS name2, t0.billing_address AS billing_address3, t0.contact_name AS contact_name4, t0.contact_email_address AS contact_email_address5, t0.contact_phone_number AS contact_phone_number6 FROM client t0 INFO - Matched route "admin_bundle_menu_menuitem_create" (parameters: "_controller": "Sonata\AdminBundle\Controller\CRUDController::createAction", "_sonata_admin": "symfony_cmf_menu.admin", "_sonata_name": "admin_bundle_menu_menuitem_create", "_route": "admin_bundle_menu_menuitem_create") DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\LocaleListener::onKernelRequest". DEBUG - Notified event "kernel.request" to listener "Symfony\Component\Security\Http\Firewall::onKernelRequest". DEBUG - Read SecurityContext from the session DEBUG - Reloading user from user provider. DEBUG - SELECT t1.username AS username2, t1.username_canonical AS username_canonical3, t1.email AS email4, t1.email_canonical AS email_canonical5, t1.enabled AS enabled6, t1.salt AS salt7, t1.password AS password8, t1.last_login AS last_login9, t1.locked AS locked10, t1.expired AS expired11, t1.expires_at AS expires_at12, t1.confirmation_token AS confirmation_token13, t1.password_requested_at AS password_requested_at14, t1.roles AS roles15, t1.credentials_expired AS credentials_expired16, t1.credentials_expire_at AS credentials_expire_at17, t1.id AS id18, t1.fb_uid AS fb_uid19, t1.tw_uid AS tw_uid20, t0.categorySelectFlag AS categorySelectFlag21, t0.paypalName AS paypalName22, t1.type FROM seeder t0 INNER JOIN user t1 ON t0.id = t1.id WHERE t1.id = ? LIMIT 1 DEBUG - SELECT t1.username AS username2, t1.username_canonical AS username_canonical3, t1.email AS email4, t1.email_canonical AS email_canonical5, t1.enabled AS enabled6, t1.salt AS salt7, t1.password AS password8, t1.last_login AS last_login9, t1.locked AS locked10, t1.expired AS expired11, t1.expires_at AS expires_at12, t1.confirmation_token AS confirmation_token13, t1.password_requested_at AS password_requested_at14, t1.roles AS roles15, t1.credentials_expired AS credentials_expired16, t1.credentials_expire_at AS credentials_expire_at17, t1.id AS id18, t1.fb_uid AS fb_uid19, t1.tw_uid AS tw_uid20, t0.client_id AS client_id21, t1.type FROM manager t0 INNER JOIN user t1 ON t0.id = t1.id WHERE t1.id = ? LIMIT 1 DEBUG - Username "admin" was reloaded from user provider. DEBUG - Notified event "kernel.request" to listener "Doctrine\Bundle\PHPCRBundle\EventListener\LocaleListener::onKernelRequest". DEBUG - Notified event "kernel.request" to listener "Symfony\Bundle\AsseticBundle\EventListener\RequestListener::onKernelRequest". DEBUG - Notified event "kernel.request" to listener "MyProject\MyBundle\Listener\Kernel::onKernelRequest". DEBUG - Notified event "kernel.controller" to listener "Symfony\Bundle\FrameworkBundle\DataCollector\RouterDataCollector::onKernelController". DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\ControllerListener::onKernelController". DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\ParamConverterListener::onKernelController". DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\TemplateListener::onKernelController". DEBUG - Notified event "kernel.controller" to listener "Acme\DemoBundle\EventListener\ControllerListener::onKernelController". DEBUG - Notified event "kernel.controller" to listener "Symfony\Component\HttpKernel\DataCollector\RequestDataCollector::onKernelController". DEBUG - Notified event "kernel.exception" to listener "Symfony\Component\Security\Http\Firewall\ExceptionListener::onKernelException". DEBUG - Notified event "kernel.exception" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelException". DEBUG - Notified event "kernel.exception" to listener "Symfony\Component\HttpKernel\EventListener\ExceptionListener::onKernelException". CRITICAL - Doctrine\Common\Persistence\Mapping\MappingException: The class 'Symfony\Cmf\Bundle\MenuBundle\Document\MenuItem' was not found in the chain configured namespaces Doctrine\ODM\PHPCR\Document (uncaught exception) at /var/www/likeseed/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/MappingException.php line 38 DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelRequest". DEBUG - Notified event "kernel.request" to listener "Symfony\Bundle\FrameworkBundle\EventListener\SessionListener::onKernelRequest". DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\RouterListener::onKernelRequest". DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\LocaleListener::onKernelRequest". DEBUG - Notified event "kernel.request" to listener "Symfony\Component\Security\Http\Firewall::onKernelRequest". DEBUG - Notified event "kernel.request" to listener "Doctrine\Bundle\PHPCRBundle\EventListener\LocaleListener::onKernelRequest". DEBUG - Notified event "kernel.request" to listener "Symfony\Bundle\AsseticBundle\EventListener\RequestListener::onKernelRequest". DEBUG - Notified event "kernel.request" to listener "MyProject\MyBundle\Listener\Kernel::onKernelRequest". DEBUG - Notified event "kernel.controller" to listener "Symfony\Bundle\FrameworkBundle\DataCollector\RouterDataCollector::onKernelController". DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\ControllerListener::onKernelController". DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\ParamConverterListener::onKernelController". DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\TemplateListener::onKernelController". DEBUG - Notified event "kernel.controller" to listener "Acme\DemoBundle\EventListener\ControllerListener::onKernelController". DEBUG - Notified event "kernel.controller" to listener "Symfony\Component\HttpKernel\DataCollector\RequestDataCollector::onKernelController".
user1597674I had added in doctrine_phpcr part of config.yml this:
odm: auto_mapping: true
And now it is works.
JohnPoisonError explains itself. I guess you should look for missing MenuItem class and place it in the correct namespace