cyril-verloop / doctrine-properties
Some default doctrine entity/fields requiring PHP >=8.5 and Doctrine ORM 3.6.
Package info
github.com/cyrilverloop/doctrine-properties
pkg:composer/cyril-verloop/doctrine-properties
Fund package maintenance!
Requires
- php: >=8.5
- doctrine/orm: ^3.6
This package is auto-updated.
Last update: 2026-04-11 10:01:55 UTC
README
Some default doctrine entity/fields requiring PHP >=8.5 and Doctrine ORM >=3.6.
This project is not yet stable.
This includes :
-
AbstractIntId: a mapped superclass with an$idas an integer identifier/primary key; -
IntIdInterface: an interface for integer id; -
BoolExample: a class with$active,$availableboolean properties; -
IntExample: a class with$priorityinteger property; -
NullableStringExample: a class with$description,$email,$firstname,$lastname,$name,$slugand$surnamenullable string properties; -
StringExample: a class that adds$description,$email,$firstname,$lastname,$name,$slugand$surnamestring properties;
Installation
As a Composer depedency
In your project directory run
user@host project$ composer require "cyril-verloop/doctrine-properties"
For development purposes
user@host ~$ cd [PATH_WHERE_TO_PUT_THE_PROJECT] # E.g. ~/projects/ user@host projects$ git clone https://github.com/cyrilverloop/doctrine-properties.git user@host projects$ cd doctrine-properties user@host doctrine-properties$ composer install -o user@host doctrine-properties$ phive install --trust-gpg-keys 4AA394086372C20A,99BF4D9A33D65E1E,6DA3ACC4991FFAE5,C5095986493B4AA0
Mappings
There are attributes and XML mappings.
Symfony
To use with Symfony, copy the attribute or XML configuration below
and add it to the config/packages/doctrine.yaml file of your project.
doctrine: orm: mappings: # For attribute : CVDP: alias: CVDP dir: '%kernel.project_dir%/vendor/cyril-verloop/doctrine-properties/src' prefix: 'CyrilVerloop\DoctrineProperties' type: attribute # For XML : CVDP: alias: CVDP dir: '%kernel.project_dir%/vendor/cyril-verloop/doctrine-properties/config/doctrine' prefix: CyrilVerloop\DoctrineProperties type: xml
You can also look at the resources/config/packages/doctrine.yaml file.
XML
Entity
The XML file is located in the config/doctrine/ directory.
You just have to copy or reference it depending on your needs.
Properties
You need to copy the require configuration in your XML file.
For example :
<id name="id" type="integer"> <generator strategy="AUTO" /> <options> <option name="unsigned">true</option> </options> </id> <field name="active" column="active" type="boolean" /> <field name="available" column="available" type="boolean" /> <field name="priority" column="priority" type="smallint"> <options> <option name="default">0</option> </options> </field> <field name="description" column="description" type="text" /> <field name="description" column="description" type="text" nullable="true" /> <field name="email" column="email" type="string" /> <field name="email" column="email" type="string" nullable="true" /> <field name="firstname" column="firstname" type="string" /> <field name="firstname" column="firstname" type="string" nullable="true" /> <field name="lastname" column="lastname" type="string" /> <field name="lastname" column="lastname" type="string" nullable="true" /> <field name="name" column="name" type="string" /> <field name="name" column="name" type="string" nullable="true" /> <field name="surname" column="surname" type="string" /> <field name="surname" column="surname" type="string" nullable="true" /> <field name="slug" column="slug" type="string" /> <field name="slug" column="slug" type="string" nullable="true" />
You can also look at the resources/mappings/Example.orm.xml file.
Usage
AbstractIntId / IntIdInterface
If your entities need an integer as an identifier/primary key :
- they can extend the mapped super class
CyrilVerloop\DoctrineProperties\AbstractIntId
use CyrilVerloop\DoctrineProperties\AbstractIntId; class Product extends AbstractIntId { public function __construct() { // You can call the parent constructor // to initiate the id to null // or initiate it yourself : parent::__construct(); } }
- implement the
CyrilVerloop\DoctrineProperties\IntIdInterfaceinterface
use CyrilVerloop\DoctrineProperties\IntIdInterface; class Product implements IntIdInterface { // Your code here. }
Properties
Example properties are in *Example.php files.
Unit tests
Example unit tests for PHPUnit are in ./tests/.
Continuous integration
Tests
To run the tests :
user@host doctrine-properties$ ./tools/phpunit -c ./ci/phpunit.xml
The generated outputs will be in ./ci/phpunit/.
Look at ./ci/phpunit/html/index.html for code coverage
and ./ci/phpunit/testdox.html for a verbose list of passing / failing tests.
To run mutation testing, you must run PHPUnit first, then :
user@host doctrine-properties$ ./tools/infection -c./ci/infection.json
The generated outputs will be in ./ci/infection/.
Static analysis
To do a static analysis :
user@host doctrine-properties$ ./tools/psalm -c ./ci/psalm.xml [--report=./psalm/psalm.txt --output-format=text]
Use "--report=./psalm/psalm.txt --output-format=text" if you want the output in a file instead of on screen.
PHPDoc
To generate the PHPDoc :
user@host doctrine-properties$ ./tools/phpdocumentor --config ./ci/phpdoc.xml
The generated HTML documentation will be in ./ci/phpdoc/.