我觉得这个错误:
属性中的注释'@Enum' 从未导入Doctrine \ ORM \ Mapping \ GeneratedValue :: $ strategy。难道 你可能忘记为这个注释添加一个'use'语句?
我只想尝试序列化一个paginator对象:
$paginator = new Paginator($query, $fetchJoinCollection = true);
$serializer = \JMS\Serializer\SerializerBuilder::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...
答案 0 :(得分:2)
这是JMSSerializer的Github页面上的一个主题:https://github.com/schmittjoh/JMSSerializerBundle/issues/380
将非实体结果传递给Serializer会产生这样的错误。
基本上,您不应该将分页器传递给序列化程序,您应该传递分页器执行结果,因为序列化程序不知道如何处理Paginator
。