PHP code example of enumeum / doctrine-enums-bundle
1. Go to this page and download the library: Download enumeum/doctrine-enums-bundle 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/ */
namespace App\Enums;
use Enumeum\DoctrineEnum\Attribute\EnumType;
#[EnumType(name: 'status_type')]
enum StatusType: string
{
case STARTED = 'started';
case PROCESSING = 'processing';
case FINISHED = 'finished';
}
namespace App\Entities;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use App\Enum\StatusType;
/**
* @ORM\Entity
* @ORM\Table(name="entity")
*/
#[ORM\Entity]
#[ORM\Table(name: 'entity')]
class Entity
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
*/
#[ORM\Id]
#[ORM\Column(type: Types::INTEGER)]
private int $id;
/**
* @ORM\Column(type="string", enumType=StatusType::class, options={"comment":"Comment"})
*/
#[ORM\Column(type: Types::STRING, enumType: StatusType::class, options: ['comment' => 'Comment'])]
private StatusType $status;
public function __construct(
int $id,
StatusType $status,
) {
$this->id = $id;
$this->status = $status;
}
public function getId(): int
{
return $this->id;
}
public function getStatus(): StatusType
{
return $this->status;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.