PHPackages                             cyril-verloop/doctrine-entities - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. cyril-verloop/doctrine-entities

ActiveLibrary[Database &amp; ORM](/categories/database)

cyril-verloop/doctrine-entities
===============================

Some default doctrine entity/fields requiring PHP &gt;=8.2 and Doctrine ORM 3.2.

10.1.0(3mo ago)01.8k↓50%MITPHPPHP &gt;=8.2CI passing

Since Feb 22Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/cyrilverloop/doctrine-entities)[ Packagist](https://packagist.org/packages/cyril-verloop/doctrine-entities)[ GitHub Sponsors](https://github.com/cyrilverloop)[ RSS](/packages/cyril-verloop-doctrine-entities/feed)WikiDiscussions trunk Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (23)Used By (0)

doctrine-entities
=================

[](#doctrine-entities)

Some default doctrine entity/fields requiring PHP &gt;=8.2 and Doctrine ORM &gt;=3.2.

For compatibility with Doctrine ORM &lt;3.2 , see version &lt;8.0 of this software.

This includes :

- `AbstractIntId` : a mapped superclass with an `$id` as an integer identifier/primary key;
- `IntId` : a trait that adds an `$id` as an integer identifier/primary key;
- `IntIdInterface` : an interface for integer id;
- `Active` : a trait that adds an `$active` boolean field;
- `Available` : a trait that adds an `$available` boolean field;
- `Priority` : a trait that adds a `$priority` integer field;
- `Slug` : a trait that adds a `$slug` text field;
- `Name` : a trait that adds a `$name` text field;
- `Description` : a trait that adds a `$description` text field;
- `NullableDescription` : a trait that adds a nullable `$description` text field;
- `ConnectedAt` : two traits that add a `$connectedAt` field (choose between \\DateTime() or \\DateTimeImmutable());
- `CreatedAt` : two traits that add a `$createdAt` field (choose between \\DateTime() or \\DateTimeImmutable());
- `UpdatedAt` : two traits that add a `$updatedAt` field (choose between \\DateTime() or \\DateTimeImmutable()).

[![License](https://camo.githubusercontent.com/082dbfff2904b7605f9b77e7e63d77b9e8896e999e0bd9f8db285373ac7c1639/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f637972696c7665726c6f6f702f646f637472696e652d656e746974696573)](https://github.com/cyrilverloop/doctrine-entities/blob/trunk/LICENSE)[![Type coverage](https://camo.githubusercontent.com/cf1f32b208c614648d851d82e4a1cd51bcfaaf66417323cfff95723e6d2c76e9/68747470733a2f2f73686570686572642e6465762f6769746875622f637972696c7665726c6f6f702f646f637472696e652d656e7469746965732f636f7665726167652e737667)](https://shepherd.dev/github/cyrilverloop/doctrine-entities)[![Minimum PHP version](https://camo.githubusercontent.com/77f44f4456af05a0ddf1f32820e4a14658bbb1436b17b992bba287c6cb4bb810/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e322d2532333737374242343f6c6f676f3d706870267374796c653d666c6174)](https://www.php.net/)

Installation
------------

[](#installation)

### As a Composer depedency

[](#as-a-composer-depedency)

In your project directory run

```
user@host project$ composer require "cyril-verloop/doctrine-entities"
```

### For development purposes

[](#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-entities.git
user@host projects$ cd doctrine-entities
user@host doctrine-entities$ composer install -o
user@host doctrine-entities$ phive install --trust-gpg-keys 4AA394086372C20A,99BF4D9A33D65E1E,31C7E470E2138192,8AC0BAA79732DD42,C5095986493B4AA0
```

Mappings
--------

[](#mappings)

There are attributes and XML mappings.

### Symfony

[](#symfony)

To you 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 :
            CVDE:
                alias: CVDE
                dir: '%kernel.project_dir%/vendor/cyril-verloop/doctrine-entities/src'
                prefix: 'CyrilVerloop\DoctrineEntities'
                type: attribute

            # For XML :
            CVDE:
                alias: CVDE
                dir: '%kernel.project_dir%/vendor/cyril-verloop/doctrine-entities/config/doctrine'
                prefix: CyrilVerloop\DoctrineEntities
                type: xml
```

You can also look at the `resources/config/packages/doctrine.yaml` file.

### XML

[](#xml)

#### Entity

[](#entity)

The XML file is located in the `config/doctrine/` directory. You just have to copy or reference it depending on your needs.

#### Traits

[](#traits)

You need to copy the require configuration in your XML file.

For example :

```

        true

        0

```

You can also look at the `resources/mappings/Example.orm.xml` file.

Usage
-----

[](#usage)

### AbstractIntId / IntId / IntIdInterface

[](#abstractintid--intid--intidinterface)

If your entities need an integer as an identifier/primary key :

- they can extend the mapped super class `CyrilVerloop\DoctrineEntities\AbstractIntId`

```
