PHP code example of fasano / phprimitives-doctrine
1. Go to this page and download the library: Download fasano/phprimitives-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/ */
fasano / phprimitives-doctrine example snippets
use Fasano\PHPrimitives\Doctrine\StringPrimitiveType;
final class EmailType extends StringPrimitiveType
{
public function getName(): string
{
return 'email';
}
protected function getPrimitiveClass(): string
{
return Email::class;
}
}
use Doctrine\DBAL\Types\Type;
Type::addType('email', EmailType::class);
Type::addType('age', AgeType::class);
Type::addType('status', StatusType::class);
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
class User
{
#[ORM\Column(type: 'email')]
public Email $email;
#[ORM\Column(type: 'age')]
public Age $age;
#[ORM\Column(type: 'status')]
public Status $status;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.