1

I have one entity that won't serialize with JMS Serializer. It throws no errors just a blank screen. If I expose this entity in any of it's related entities it responds with a blank page. I've been poking at this for over a day and it's become quite frustrating. What would keep an entity from being serialized JMS Serializer? Here's a snippet of the entity. I can provide any requested material to anyone willing to help me out here.

<?php

namespace TMG\Api\ApiBundle\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;

use JMS\Serializer\Annotation as Serializer;


/**
 * Property
 *
 * @ORM\Table(name="Properties")
 * @ORM\Entity(repositoryClass="TMG\Api\ApiBundle\Entity\Repository\PropertyRepository")
 * @ORM\HasLifecycleCallbacks()
 *
 * @Serializer\ExclusionPolicy("all")
 */
 class Property
{
public function __construct()
{
    $this->featuredAmenities = [];
    $this->users = new ArrayCollection();
    $this->amenities = new ArrayCollection();
    $this->contracts = new ArrayCollection();
    $this->rates = new ArrayCollection();
    $this->photos = new ArrayCollection();
    $this->tollFrees = new ArrayCollection();
    $this->favorites = new ArrayCollection();
}

/**
 * @var integer
 *
 * @ORM\Column(name="id", type="integer")
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="AUTO")
 *
 * @Serializer\Expose
 */
private $id;

/**
 * @var string
 *
 * @ORM\Column(name="hash", type="string", length=8)
 *
 * @Serializer\Expose
 */
private $hash;

/**
 * @var string
 *
 * @ORM\Column(name="ax_number", type="string", length=40, unique=true)
 *
 * @Serializer\Expose
 */
private $axNumber;

/**
 * @var string
 *
 * @ORM\Column(name="property_number", type="string", length=40, nullable=true)
 *
 * @Serializer\Expose
 */
private $propertyNumber;

/**
 * @var string
 *
 * @ORM\Column(name="name", type="string", length=255)
 *
 * @Serializer\Expose
 */
private $name;

/**
 * @var string
 *
 * @ORM\Column(name="contact_name", type="string", length=255, nullable=true)
 *
 * @Serializer\Expose
 */
private $contactName;

/**
 * @var string
 *
 * @ORM\Column(name="email", type="string", length=255, nullable=true)
 *
 * @Serializer\Expose
 */
private $email;

/**
 * @var string
 *
 * @ORM\Column(name="fax", type="string", length=255, nullable=true)
 *
 * @Serializer\Expose
 */
private $fax;

//.....
Tim Lieberman
  • 571
  • 2
  • 5
  • 23

1 Answers1

1

Try first to expose only your id to check if you have any response, then if you have no more error, I advise you to follow the documentation to check your configuration: http://jmsyst.com/bundles/JMSSerializerBundle

Sylvain Martin
  • 2,365
  • 3
  • 14
  • 29
  • 1
    I ended up taking a previous version of this entity and replacing the current version with it. It works now. I still don't know what happened with it. weird. – Tim Lieberman Aug 05 '15 at 18:19
  • Try to see the logs of PHP: maybe the error happens before the output comes to the screen, but it is anyway in the logs. – Aerendir Aug 19 '15 at 12:55