PHP code example of headsnet / doctrine-tools-bundle
1. Go to this page and download the library: Download headsnet/doctrine-tools-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\Domain\Model;
use Headsnet\DoctrineToolsBundle\Attribute\DoctrineType;
#[DoctrineType(name: 'person_name', type: 'string')]
class PersonName
{
public function __construct(
private readonly string $value
) {
}
public static function create(string $value): self
{
return new self($value);
}
public function asString(): string
{
return $this->value;
}
}
class PersonNameType extends \Headsnet\DoctrineToolsBundle\Types\StandardTypes\AbstractStringMappingType {
public function getName(): string
{
return 'person_name';
}
public function getClass(): string
{
return 'App\Domain\Model\PersonName';
}
}
use Doctrine\DBAL\Types\Type;
use Headsnet\DoctrineToolsBundle\Attribute\DoctrineMappingType;
#[DoctrineTypeMapping]
final class ReservationIdType extends Type
{
// defines "reservation_id" type
}
#[DoctrineTypeMapping(name: 'my_reservation_id')]
final class ReservationIdType extends Type
{
// customised name "my_reservation_id" type
}