Doctrine UK Postcode Type
The preferred method of installation is via Packagist and Composer. Run
the following command to install the package and add it as a requirement to
your project's composer.json
:
composer require vasildakov/postcode-doctrine
To configure Doctrine to use vasildakov/postcode as a field type, you'll need to set up the following in your bootstrap:
\Doctrine\DBAL\Types\Type::addType('postcode', 'VasilDakov\Postcode\Doctrine\PostcodeType');
Then, in your models, you may annotate properties by setting the @Column
type to postcode
.
/**
* @Entity
* @Table(name="address")
*/
class Address
{
/**
* @var \VasilDakov\Postcode\Postcode
* @Column(type="postcode")
*/
protected $postcode;
public function getPostcode()
{
return $this->postcode;
}
}
The vasildakov/postcode-doctrine library is copyright © Vasil Dakov and licensed for use under the MIT License (MIT). Please see [LICENSE][] for more information.