nucleos / doctrine-extensions
Useful doctrine event hooks.
Fund package maintenance!
core23
Opencollective
Ko-Fi
Other
Installs: 30 219
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 1
Open Issues: 5
Requires
- php: ^8.1
- doctrine/common: ^2.12 || ^3.0
- doctrine/dbal: ^3.8 || ^4.0
- doctrine/event-manager: ^1.0 || ^2.0
- doctrine/orm: ^2.18 || ^3.0
- doctrine/persistence: ^1.3 || ^2.0 || ^3.0
- symfony/property-access: ^6.4 || ^7.0
- symfony/uid: ^6.4 || ^7.0
Requires (Dev)
- doctrine/doctrine-bundle: ^2.5
- doctrine/doctrine-migrations-bundle: ^3.2
- ergebnis/composer-normalize: ^2.0.1
- symfony/browser-kit: ^6.4 || ^7.0
- symfony/dependency-injection: ^6.4 || ^7.0
- symfony/expression-language: ^6.4 || ^7.0
- symfony/framework-bundle: ^6.4 || ^7.0
Suggests
- symfony/framework-bundle: If you want to use symfony
Conflicts
- doctrine/doctrine-bundle: <2.5
- symfony/framework-bundle: <6.4
- 4.16.x-dev
- 4.15.x-dev
- 4.15.0
- 4.14.x-dev
- 4.14.0
- 4.13.x-dev
- 4.13.0
- 4.12.x-dev
- 4.12.0
- 4.11.x-dev
- 4.11.0
- 4.10.x-dev
- 4.10.0
- 4.9.x-dev
- 4.9.0
- 4.8.x-dev
- 4.8.1
- 4.8.0
- 4.7.x-dev
- 4.7.2
- 4.7.1
- 4.7.0
- 4.6.x-dev
- 4.6.0
- 4.5.x-dev
- 4.5.0
- 4.4.x-dev
- 4.4.0
- 4.3.x-dev
- 4.3.0
- 4.2.x-dev
- 4.2.0
- 4.1.0
- 4.0.0
- 3.3.0
- 3.2.0
- 3.1.0
- 3.0.0
- 2.0.0
- 1.0.0
- 0.3.0
- 0.2.2
- 0.2.1
- 0.2.0
- 0.1.0
- dev-renovate/phpunit-phpunit-11.x
- dev-renovate/matthiasnoback-symfony-dependency-injection-test-6.x
- dev-readme-badge
- dev-dependabot/composer/vendor-bin/tools/symplify/changelog-linker-9.0.40
This package is auto-updated.
Last update: 2024-09-14 20:20:19 UTC
README
This library provides adds some useful doctrine hooks.
Installation
Open a command console, enter your project directory and execute the following command to download the latest stable version of this library:
composer require nucleos/doctrine-extensions
Usage
Confirmable entities
If you need entities that needs to be confirmed, just implement the Nucleos\Doctrine\Model\ConfirmableInterface
in your entity class.
If you don't need the symfony framework, you need to register the Nucleos\Doctrine\EventListener\ORM\ConfirmableListener
.
Deleteable entities
If you need entities that should be soft deleted, just implement the Nucleos\Doctrine\Model\DeletableInterface
in your entity class.
If you don't need the symfony framework, you need to register the Nucleos\Doctrine\EventListener\ORM\DeletableListener
.
Lifecyle aware enties
If you need lifecyle information (creation / update date), just implement the Nucleos\Doctrine\Model\LifecycleDateTimeInterface
in your entity class.
If you don't need the symfony framework, you need to register the Nucleos\Doctrine\EventListener\ORM\LifecycleDateListener
.
Position aware entities
If you need sortable entities, just implement the Nucleos\Doctrine\Model\PositionAwareInterface
in your entity class.
If you don't need the symfony framework, you need to register the Nucleos\Doctrine\EventListener\ORM\SortableListener
.
Unique active entities
If you need entities that should only have one active state, just implement the Nucleos\Doctrine\Model\UniqueActiveInterface
in your entity class.
If you don't need the symfony framework, you need to register the Nucleos\Doctrine\EventListener\ORM\UniqueActiveListener
.
Table prefix
If you need a prefix for all of you application tables and sequences, you could use the TablePrefixEventListener
.
If the table name does already start with the defined prefix, it will be ignored.
If you don't need the symfony framework, you need to register the Nucleos\Doctrine\EventListener\ORM\TablePrefixEventListener
.
Migration usage
-
Update your
id
column frominteger
toguid
. -
Create a new migration:
// src/Migrations/Version123.php <?php namespace Application\Migrations; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; use Nucleos\Doctrine\Migration\IdToUuidMigration; class Version123 extends AbstractMigration { private IdToUuidMigration $idToUuidMigration; public function __construct(Connection $connection, LoggerInterface $logger) { parent::__construct($connection, $logger); $this->idToUuidMigration = new IdToUuidMigration($this->connection, $logger); } public function postUp(Schema $schema): void { $this->idToUuidMigration->migrate('my_table_name'); } }
Symfony usage
If you want to use this library inside symfony, you can use a bridge.
Enable the Bundle
Then, enable the bundle by adding it to the list of registered bundles in config/bundles.php
file of your project:
// config/bundles.php return [ // ... Nucleos\Doctrine\Bridge\Symfony\Bundle\NucleosDoctrineBundle::class => ['all' => true], ];
Configure the Bundle
Create a configuration file called nucleos_doctrine.yaml
:
# config/packages/nucleos_doctrine.yaml nucleos_doctrine: table: prefix: 'acme_'
License
This library is under the MIT license.