We are having issues autoloading JMSSerializer annotations in a symfony app. We are getting:
[Semantical Error] The annotation "@JMS\Serializer\Annotation\XMLRoot" in class Class\Namespace\ClassName does not exist, or could not be auto-loaded.
We are using the standard symfony/composer autoloader, have "jms/serializer-bundle": "~1.0"
required in composer.json, and include the bundle in the AppKernel. Other annotations (e.g symfony route annotations) work correctly.
We tried forcing to load the jms serializer annotations by modifying app_dev.php to:
<?php
use Doctrine\Common\Annotations\AnnotationRegistry;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Debug\Debug;
// If you don't want to setup permissions the proper way, just uncomment the following PHP line
// read http://symfony.com/doc/current/book/installation.html#configuration-and-setup for more information
//umask(0000);
$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
Debug::enable();
require_once __DIR__.'/../app/AppKernel.php';
AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
AnnotationRegistry::registerFile("/srv/httpd/project/vendor/jms/serializer/src/JMS/Serializer/Annotation/XmlRoot.php");
AnnotationRegistry::registerAutoloadNamespace('JMS\Serializer', "/srv/httpd/project/vendor/jms/serializer/src/");
$kernel = new AppKernel('dev', true);
$kernel->loadClassCache();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
We tried several variations of the AnnotationRegistery::...
calls. AnnotationRegistry::registerFile("/srv/httpd/project/vendor/jms/serializer/src/JMS/Serializer/Annotation/XmlRoot.php");
seems to register correctly the XmlRoot annotations but other JMS annotations still fail.
Thanks.
use JMS\Serializer\Annotation as JMS
and the annotation is@JMS\XMLRoot
– roinir