PHP code example of gusarov112 / php-enum-doctrine
1. Go to this page and download the library: Download gusarov112/php-enum-doctrine library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
gusarov112 / php-enum-doctrine example snippets
class PetEnum extends \Gusarov112\Enum\Enum
{
const CAT = 'CAT';
const DOG = 'DOG';
}
class PetType extends \Gusarov112\PhpEnumDoctrine\DBAL\EnumType
{
public function getEnumClassName(): string
{
return PetEnum::class;
}
public function getName()
{
return 'pet_type';
}
}
use Doctrine\ORM\Mapping as ORM;
class PetEntity {
/**
* @var PetEnum
* @ORM\Column(type="pet_type")
*/
private $type;
public function getType(): PetEnum
{
return $this->type;
}
public function setType(PetEnum $type): self
{
$this->type = $type;
return $this;
}
}