PHP code example of bentools / doctrine-native-enums
1. Go to this page and download the library: Download bentools/doctrine-native-enums 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/ */
declare(strict_types=1);
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
final class Book
{
#[
ORM\Id,
ORM\Column(unique: true),
ORM\GeneratedValue(strategy: 'AUTO'),
]
public int $id;
#[ORM\Column]
public string $name;
#[ORM\Column(type: StatusEnum::class)]
public StatusEnum $status;
}
use App\Entity\StatusEnum;
use BenTools\Doctrine\NativeEnums\Type\NativeEnum;
use Doctrine\DBAL\Types\Type;
NativeEnum::registerEnumType(StatusEnum::class);
// NativeEnum::registerEnumType('status', StatusEnum::class); // Alternatively, if you want your type to be named "status"
bash
php vendor/bin/pest
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.