1. Go to this page and download the library: Download jdecool/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/ */
jdecool / enum-doctrine example snippets
use JDecool\Enum\Enum;
class MyEnum extends Enum
{
public const ENUM_1 = 'value_1';
protected const ENUM_2 = 'value_2';
private const ENUM_3 = 'value_3';
}
class User
{
// ...
/**
* @var MyEnum
*
* @ORM\Column(type=MyEnum::class, length=10)
*/
protected $action;
// ...
}
// in bootstrapping code
use JDecool\Enum\Doctrine\EnumType;
EnumType::registerEnumType(MyEnum::class);
// Don't forget to register the enums for schema operations
$platform = $em->getConnection()->getDatabasePlatform();
$platform->registerDoctrineTypeMapping('VARCHAR', MyEnum::class);
// ...
use JDecool\Enum\Doctrine\EnumType;
EnumType::registerEnumTypes([
MyEnum::class,
'php_enum_type' => MyEnum::class,
]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.