This library provides adds some useful doctrine hooks.
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
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
.
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
.
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
.
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
.
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
.
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
.
-
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');
}
}
If you want to use this library inside symfony, you can use a bridge.
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],
];
Create a configuration file called nucleos_doctrine.yaml
:
# config/packages/nucleos_doctrine.yaml
nucleos_doctrine:
table:
prefix: 'acme_'
This library is under the MIT license.