PHP code example of neutronstars / doctrine-enum-php-type

1. Go to this page and download the library: Download neutronstars/doctrine-enum-php-type 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/ */

    

neutronstars / doctrine-enum-php-type example snippets


namespace App\Types;

class MyEnumType extends \NeutronStars\Enum\Types\EnumType {
  public const MY_ENUM = 'my_enum';
  
  public function getName(): string
  {
    return self::MY_ENUM;
  }
  
  public function convertToPHPValue($value,\Doctrine\DBAL\Platforms\AbstractPlatform $platform): MyEnum
  {
    return MyEnum::from($value);
  }
}

/**
 * @ORM\Column(type="my_enum")
 * @var MyEnum|null
 */
private ?MyEnum $myEnum;

$this->addSql('COMMENT ON COLUMN "your_table"."your_column" IS \'(DC2Type:my_enum)\';');