Using Doctrine, I am being presented the following error:
[2016-09-14 21:24:44] request.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\DBALException: "Unknown column type "varchar" requested. Any Doctrine type that you use has to be registered with \Doctrine\DBAL\Types\Type::addType(). You can get a list of all the known types with \Doctrine\DBAL\Types\Type::getTypeMap(). If this error occurs during database introspection then you might have forgot to register all database types for a Doctrine Type. Use AbstractPlatform#registerDoctrineTypeMapping() or have your custom types implement Type#getMappedDatabaseTypes(). If the type name is empty you might have a problem with the cache or forgot some mapping information." at /var/www/project/apps/ProjectName/trunk/vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php line 114 {"exception":"[object] (Doctrine\\DBAL\\DBALException(code: 0): Unknown column type \"varchar\" requested. Any Doctrine type that you use has to be registered with \\Doctrine\\DBAL\\Types\\Type::addType(). You can get a list of all the known types with \\Doctrine\\DBAL\\Types\\Type::getTypeMap(). If this error occurs during database introspection then you might have forgot to register all database types for a Doctrine Type. Use AbstractPlatform#registerDoctrineTypeMapping() or have your custom types implement Type#getMappedDatabaseTypes(). If the type name is empty you might have a problem with the cache or forgot some mapping information. at /var/www/project/apps/ProjectName/trunk/vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php:114)"} []
the relevant class looks as such
<?php
namespace Project\DBALBundle\Entity\Url;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as JMSS;
/**
* Profile
*
* @ORM\Table(name="Profile")
* @ORM\Entity(repositoryClass="Project\DBALBundle\Entity\Url\ProfileRepository")
*/
class ProfileRepository {
/**
* @var string $id
*
* @ORM\Column(name="id", type="integer", length=11, nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string $label
*
* @ORM\Column(name="label", type="string", length=50, nullable=false)
*/
private $label;
/**
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* @param string $id
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return string
*/
public function getLabel()
{
return $this->label;
}
/**
* @param string $label
*/
public function setLabel($label)
{
$this->label = $label;
}
public function __toString()
{
return $this->label;
}
}
With the above class and annotation-defined mappings, I receive the error. However, if I change the field private $label
to private $labelField
and update the associated references, everything works just fine and the data is accessed as expected.
Insofar as I have been able to search, there is nothing special about the field private $label
. It is not a reserved keyword, and I can find nothing mentioning anything special about it either with PHP itself or Doctrine specifically. So why does this break?