- Enum (based on marc-mabe/php-enum)
composer require jeckel-lab/advanced-types
See documentation of marc-mabe/php-enum.
The only addition is the implementation of
JsonSerializable
interface to serialize enum as it's value.
- Color
- DateTimePeriod
- TimeDuration
- Url
Configure type DBAL:
# config/packages/doctrine.yaml
doctrine:
dbal:
types:
color: JeckelLab\AdvancedTypes\DBAL\Types\ColorType
email: JeckelLab\AdvancedTypes\DBAL\Types\EmailType
time_duration: JeckelLab\AdvancedTypes\DBAL\Type\sTimeDurationType
url: JeckelLab\AdvancedTypes\DBAL\Types\UrlType
Use it in your entity:
<?php
use Doctrine\ORM\Mapping as ORM;
use JeckelLab\Types\ValueObject\TimeDuration;
/**
* @ORM\Entity(repositoryClass="App\Repository\TimeEntryRepository")
*/
class TimeEntry
{
// ...
/**
* @ORM\Column(type="time_duration", nullable=true)
* @var TimeDuration|null
*/
private $duration;
// ...
}