我得到这个错误:
属性中的注释"@Enum" Doctrine\ORM\Mapping\Generated Value::$strategy 从未导入。做了 您可能忘记为此注释添加"使用"语句?
我只是试图序列化一个分页器对象:
$paginator = new Paginator($query, $fetchJoinCollection = true);
$serializer = JMSSerializerSerializerBuilder::create()->build();
$jsonContent = $serializer->serialize($paginator, 'json');
这些是我安装的composer.json软件包:
doctrine/annotations v1.2.3 Docblock Annotations Parser
doctrine/cache v1.4.0 Caching library offering an objec...
doctrine/collections v1.2 Collections Abstraction library
doctrine/common v2.4.2 Common Library for Doctrine projects
doctrine/dbal v2.5.1 Database Abstraction Layer
doctrine/doctrine-bundle v1.3.0 Symfony DoctrineBundle
doctrine/doctrine-cache-bundle v1.0.1 Symfony2 Bundle for Doctrine Cache
doctrine/doctrine-migrations-bundle dev-master 81575a4 Symfony DoctrineMigrationsBundle
doctrine/inflector v1.0.1 Common String Manipulations with ...
doctrine/lexer v1.0.1 Base library for a lexer that can...
doctrine/migrations dev-master 96f838b Database Schema migrations using ...
doctrine/orm v2.4.7 Object-Relational-Mapper for PHP
gedmo/doctrine-extensions v2.3.9 Doctrine2 behavioral extensions
stof/doctrine-extensions-bundle dev-master 2ff8473 Integration of the gedmo/doctrine...
这是JMSSerializer的Github页面上的一个线程:https://github.com/schmittjoh/JMSSerializerBundle/issues/380
将非实体结果传递给序列化程序可能会产生此类错误。
基本上,您不应该将分页器传递给序列化程序,而应该传递分页器执行结果,因为序列化程序不知道如何处理Paginator
。