Giter Club home page Giter Club logo

psr-container-doctrine's People

Contributors

andersmadsen avatar arjanvdbos avatar asgrim avatar bcremer avatar boesing avatar byan avatar daniel-braga avatar dasprid avatar edigu avatar gabrielsch avatar gared avatar garygitton avatar geerteltink avatar jguittard avatar moln avatar ocramius avatar orkin avatar pauci avatar powerkiki avatar renovate[bot] avatar rieschl avatar slamdunk avatar snapshotpl avatar stefanotorresi avatar svycka avatar tobias-trozowski avatar yethee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

psr-container-doctrine's Issues

Wiring up Migrations

I just tried version 3 of this package which requires doctrine migrations v3 and it took me a while to figure out to correctly wire up the migrations CLI commands.

I added the factories as outlined in the docs (copy/paste from the full-config example) but to actually use the migration command I also had to add all migrations command to a $commands array in cli-config.php, which seems to be an (undocumented?) feature of the Doctrine CLI.

So, my question is... Did I do it wrong? If so, what is the correct way?
Should we add more documentation for this or is it obvious and I just didn't get it?
Also, should we add some possibilities to fetch the factory config and commands config (for CLI) from a helper? Searching for all possible Migrations commands is tedious.

When I was browsing the code I also noticed that the migrations stuff is neatly separated in a sub namespace, so maybe we could/should move the dependency from require to a suggestion for people who don't use migrations?

Any opinions? Thanks!

Issues with my configuration because of an issue running orm:mapping:describe

I've followed the documentation, attempting to get Mezzio integrated with Doctrine, using this package, but keep encountering the following error, when running: php vendor/bin/doctrine orm:mapping:describe QuoteUser.

You do not have any mapped Doctrine ORM entities according to the current configuration. If you have entities or mapping files you should check your mapping configuration for errors.

I'm using roave/psr-container-doctrine 3.6.0 with PHP 8.1.14.

Here is my config/autoload/doctrine.global.php file:

<?php

use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
use Doctrine\Persistence\Mapping\Driver\MappingDriverChain;
use Ramsey\Uuid\Doctrine\UuidType;
use Roave\PsrContainerDoctrine\EntityManagerFactory;

return [
    'dependencies' => [
        'factories' => [
            'doctrine.entity_manager.orm_default' => EntityManagerFactory::class,
        ],
    ],
    'doctrine' => [
        'connection' => [
            'orm_default' => [
                'params' => [
                    'url' => 'pgsql://user:password@database-test/developer_quotes_sender_test',
                ],
            ],
        ],
        'annotation' => [
            'metadata' => [
                'src/App/src/Entity',
            ],
        ],
        'entity_manager' => [
            'orm_default' => [
                'connection' => 'orm_default',
                'configuration' => 'orm_default',
            ],
        ],
        'driver' => [
            'orm_default' => [
                'class' => MappingDriverChain::class,
                'drivers' => [
                    'QuoteUser' => 'quote_user',
                ],
            ],
            'quote_user' => [
                'class' => AnnotationDriver::class,
                'cache' => 'array',
                'paths' => __DIR__ . '/../../src/App/src/Entity',
            ],
        ],
        'cache' => [
            'array' => [
                'class' => Doctrine\Common\Cache\ArrayCache::class,
                'namespace' => 'psr-container-doctrine',
            ],
        ],
        'types' => [
            UuidType::NAME => UuidType::class,
        ]
    ],
];

In src/App/src/Entity, i have one file named QuoteUser.php, with the following definition:

<?php

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use Ramsey\Uuid\Doctrine\UuidGenerator;

/**
 * @ORM\Entity
 * @ORM\Table(name="quote_users")
 */
class QuoteUser
{
    /**
     * @ORM\Id
     * @ORM\Column(type="uuid", unique=true)
     * @ORM\GeneratedValue(strategy="CUSTOM")
     * @ORM\CustomIdGenerator(class=UuidGenerator::class)
     */
    private $userId;

    /** @ORM\Column(type="string",length="36",name="full_name") */
    private $fullName;

    /** @ORM\Column(type="string",length="18",name="mobile_number",unique="true") */
    private $mobileNumber;

    /** @ORM\Column(type="text",name="email_address",unique="true") */
    private $emailAddress;
}

This is the contents of cli-config.php:

<?php

use Doctrine\ORM\Tools\Console\ConsoleRunner;

$container = require 'config/container.php';

return ConsoleRunner::createHelperSet(
    $container->get('doctrine.entity_manager.orm_default')
);

Finally, I have the following factories element in config/autoload/dependencies.global.php:

'factories' => [
    // Fully\Qualified\ClassName::class => Fully\Qualified\FactoryName::class,
    ExecuteCommand::class => CommandFactory::class,
    ConfigurationLoader::class => ConfigurationLoaderFactory::class,
    DependencyFactory::class => DependencyFactoryFactory::class,
],

Call to a member function getClassAnnotations() on array with doctrine/orm:^2.12

Moin,

the use of Doctrine\ORM\Mapping\Driver\AnnotationDriver does not work since doctrine/orm:^2.12.

Here in the https://github.com/doctrine/orm/blob/2.12.x/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php the parent class was changed to MappingDriver.

In https://github.com/Roave/psr-container-doctrine/blob/3.6.x/src/DriverFactory.php#L52 it is checked whether this is a subclass of Doctrine\Persistence\Mapping\Driver\AnnotationDriver. However, this class is deprecated and as far as I can see, no more subclasses are provided.

This then leads to the following error:

Call to a member function getClassAnnotations() on array in vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php:82

Missing configuration file when using the CLI

Please help me how to fix the error?

command php vendor/bin/doctrine-migrations migrations:diff causes an error:

    Fatal error: Uncaught Doctrine\Migrations\Configuration\Migration\Exception\MissingConfigurationFile: It was not possible to locate any configuration file. in /app/vendor/doctrine/migrations/lib/Doctrine/Migrations/Configuration/Migration/Exception/MissingConfigurationFile.php:14
    Stack trace:
    #0 /app/vendor/doctrine/migrations/lib/Doctrine/Migrations/Configuration/Migration/ConfigurationFileWithFallback.php(52): Doctrine\Migrations\Configuration\Migration\Exception\MissingConfigurationFile::new()
    #1 /app/vendor/doctrine/migrations/lib/Doctrine/Migrations/DependencyFactory.php(161): Doctrine\Migrations\Configuration\Migration\ConfigurationFileWithFallback->getConfiguration()
    #2 /app/vendor/doctrine/migrations/lib/Doctrine/Migrations/DependencyFactory.php(187): Doctrine\Migrations\DependencyFactory->getConfiguration()
    #3 /app/vendor/doctrine/migrations/lib/Doctrine/Migrations/DependencyFactory.php(279): Doctrine\Migrations\DependencyFactory->getEntityManager()
    #4 /app/vendor/doctrine/migrations/lib/Doctrine/Migrations/Depen in /app/vendor/doctrine/migrations/lib/Doctrine/Migrations/Configuration/Migration/Exception/MissingConfigurationFile.php on line 14

file cli-config.php:

    <?php
    $container = require 'config/container.php';
    /** @var \Doctrine\ORM\EntityManager $entityManager */
    $entityManager = $container->get(\Doctrine\ORM\EntityManager::class);
    return \Doctrine\ORM\Tools\Console\ConsoleRunner::createHelperSet(
        $container->get(\Doctrine\ORM\EntityManager::class)
    );

file config/autoload/doctrine.local.php:

    <?php
    declare(strict_types=1);
    use Doctrine\Migrations\Tools\Console\Command;
    return [
        'doctrine' => [
            'connection' => [
                'orm_default' => [
                    'params' => [ ],
                ],
            ],
            'migrations' => [
                'orm_default' => [
                    'table_storage' => [
                        'table_name' => 'migrations',
                        'version_column_name' => 'version',
                        'version_column_length' => 255,
                        'executed_at_column_name' => 'executed_at',
                        'execution_time_column_name' => 'execution_time',
                    ],
                    'migrations_paths' => ['DB\Migrations' => __DIR__ . '/../../data/migrations'],
                    'all_or_nothing' => true,
                    'check_database_platform' => true,
                ],
            ],
        ],
        'dependencies' => [
            'factories' => [
                Command\DiffCommand::class => Roave\PsrContainerDoctrine\Migrations\CommandFactory::class,
                Command\DumpSchemaCommand::class => Roave\PsrContainerDoctrine\Migrations\CommandFactory::class,
                Command\ExecuteCommand::class => Roave\PsrContainerDoctrine\Migrations\CommandFactory::class,
                Command\GenerateCommand::class => Roave\PsrContainerDoctrine\Migrations\CommandFactory::class,
                Command\LatestCommand::class => Roave\PsrContainerDoctrine\Migrations\CommandFactory::class,
                Command\MigrateCommand::class => Roave\PsrContainerDoctrine\Migrations\CommandFactory::class,
                Command\RollupCommand::class => Roave\PsrContainerDoctrine\Migrations\CommandFactory::class,
                Command\StatusCommand::class => Roave\PsrContainerDoctrine\Migrations\CommandFactory::class,
                Command\UpToDateCommand::class => Roave\PsrContainerDoctrine\Migrations\CommandFactory::class,
                Command\VersionCommand::class => Roave\PsrContainerDoctrine\Migrations\CommandFactory::class,
                Doctrine\Migrations\DependencyFactory::class => Roave\PsrContainerDoctrine\Migrations\DependencyFactoryFactory::class,
                Doctrine\Migrations\Configuration\Migration\ConfigurationLoader::class => Roave\PsrContainerDoctrine\Migrations\ConfigurationLoaderFactory::class,
            ],
        ],
    ];

Undefined index: default_driver

I've just switched from the DASPRiD package and get the Laminas\ServiceManager\Exception\ServiceNotCreatedException thrown upon my previously working configuration:

Service with name "Doctrine\ORM\EntityManager" could not be created. Reason: Undefined index: default_driver

I went through the readme and the sample configurations but found no clue as far as 'default_driver' is concerned.

What works is the following change in DriverFactory.php:71
if (@$config['default_driver'] !== null) {

DriverFactory doesn't work with Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain

Hello

I'm switching between the repository of Dasprid and that of Roave.
I have the following configuration for the configuration of my entityManager.

use Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain;

return [
    'driver' => [
        'domain' => [
            'class' => MappingDriverChain::class,
            'drivers' => [
                'Domain' => 'domain_entity'
            ],
        ],
        'domain_entity' => [
            'class' => XmlDriver::class,
            'paths' => __DIR__ . '/../src/Infrastructure/Mapping',
        ]
    ]
];

When I instantiate the entityManager I get the following error: (For information it worked correctly with Dasprid services)
The class 'Domain\Account\Entity\User' was not found in the chain configured namespaces.

If I understand correctly, the problem comes from the Factory DriverFactory
which tests if the driver and type is an instance Doctrine\Persistence\Mapping\Driver\MappingDriverChain and not an instance of Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain as described in the example of minimal configuration

Except I do not use the Doctrine\Persistence library, it is also not required in the composer.
So, what should I do ? Install 'Doctrine\Persistence' and use it in my configuration ?

Thank you in advance for your help.

DriverFactory incompatible with AttributeDriver

The DriverFactory assumes that any subclass of AnnotationDriver will maintain its constructor signature:

if (is_subclass_of($config['class'], AnnotationDriver::class)) {
$this->registerAnnotationLoader();
/**
* @psalm-suppress UndefinedClass
* @psalm-suppress UnsafeInstantiation
*/
$driver = new $config['class'](
new CachedReader(
new AnnotationReader(),
$this->retrieveDependency($container, $config['cache'], 'cache', CacheFactory::class)
),
$config['paths']
);
}

AttributeDriver redefines the constructor:

https://github.com/doctrine/orm/blob/f3e55fae9fdbdbc23897006bdbf016c20e11f6e9/lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php#L36-L39

I'm working around this for now with a wrapper class:

<?php
declare(strict_types=1);

namespace MyData;

class AttributeDriver extends \Doctrine\ORM\Mapping\Driver\AttributeDriver
{
    /**
     * Redefine constructor to work around argument bug since
     * \Doctrine\ORM\Mapping\Driver\AttributeDriver redefined the constructor
     * and changed the arguments while the Roave factory assumes the same
     * arguments as the parent AnnotationDriver
     */
    public function __construct($reader, $paths = null)
    {
        parent::__construct($paths);
    }
}

Add contributors

Since the original package should be credited to @DASPRiD clearly, add a note about this in the readme.

Migrations: Document how to use a custom version comparator

It's come up a couple of times in laminas' slack the question as to how to use a custom version comparator in doctrine migrations when using this library.

That should be documented, and the one I've been sharing is:

config/cli-config.php

<?php

declare(strict_types=1);

use Doctrine\Migrations\DependencyFactory;
use Doctrine\Migrations\Version\Comparator;
use Doctrine\Migrations\Version\Version;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Tools\Console\EntityManagerProvider\SingleManagerProvider;
use Laminas\ServiceManager\ServiceManager;

require dirname(__DIR__) . '/vendor/autoload.php';

/** @var ServiceManager $container */
$container = require __DIR__ . '/container.php';

global $argv;
if (str_contains($argv[0], 'doctrine-migrations')) {
    /** @var DependencyFactory $factory */
    $factory = $container->get(DependencyFactory::class);
    $factory->setService(Comparator::class, new class() implements Comparator {
        public function compare(Version $a, Version $b): int
        {
            return strcmp(self::versionWithoutNamespace($a), self::versionWithoutNamespace($b));
        }
        private static function versionWithoutNamespace(Version $version): string
        {
            $parsed = strrchr($version->__toString(), '\\');
            if ($parsed === false) {
                throw new \RuntimeException('Unable to parse version ' . $version->__toString());
            }

            return $parsed;
        }
    });

    return $factory;
}

When run as: vendor/bin/doctrine-migrations ...

This example uses laminas service manager, and adds an anonymous class as the comparator, which compares version numbers regardless of their namespace, so that they can be run in order across different modules.

If no one beats me to it, I'll try to remember to create a PR for this if it would be welcome. I know its not just for this library, but everything else is pretty much available by configuration, so this comes up.

Doctrine Migrations - Missing configuration in cli-config.php

The current documentation suggests the following configuration:

return new HelperSet(
    [
        'em' => new EntityManagerHelper(
            $container->get('doctrine.entity_manager.orm_default')
        ),
    ]
);

However, when I try to run php vendor/bin/doctrine-migrations migrations:status, it says that I have to provide a configuration for the database. The exact error is the following: You have to specify a --db-configuration file or pass a Database Connection as a dependency to the Migrations.. Shouldn't we actually make it as follows?

/** @var EntityManagerInterface $entityManager */
$entityManager = $container->get('doctrine.entity_manager.orm_default');

return new HelperSet(
    [
        'em'            => new EntityManagerHelper(
            $entityManager
        ),
        'configuration' => new ConfigurationHelper(
            $entityManager->getConnection(),
            $container->get('doctrine.migrations.orm_default')
        ),
    ]
);

Functional config example for doctrine with mezzio

Hello, there!
I'm struggling for 3 days to configure the roave/psr-container-doctrine with mezzio.

First I struggled with caches, then with MappingDriver, now I managed to make it all work, but it doesn't recognize entities.
This is my exception:

Doctrine\ORM\Mapping\MappingException: Class &quot;Usuario\Entity\Usuario&quot; is not a valid entity or mapped super class. in file /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/MappingException.php on line 378

Stack trace:
  1. Doctrine\ORM\Mapping\MappingException-&gt;() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/MappingException.php:378
  2. Doctrine\ORM\Mapping\MappingException-&gt;classIsNotAValidEntityOrMappedSuperClass() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php:101
  3. Doctrine\ORM\Mapping\Driver\AnnotationDriver-&gt;loadMetadataForClass() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/doctrine/persistence/lib/Doctrine/Persistence/Mapping/Driver/MappingDriverChain.php:79
  4. Doctrine\Persistence\Mapping\Driver\MappingDriverChain-&gt;loadMetadataForClass() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:156
  5. Doctrine\ORM\Mapping\ClassMetadataFactory-&gt;doLoadMetadata() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/doctrine/persistence/lib/Doctrine/Persistence/Mapping/AbstractClassMetadataFactory.php:382
  6. Doctrine\Persistence\Mapping\AbstractClassMetadataFactory-&gt;loadMetadata() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:85
  7. Doctrine\ORM\Mapping\ClassMetadataFactory-&gt;loadMetadata() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/doctrine/persistence/lib/Doctrine/Persistence/Mapping/AbstractClassMetadataFactory.php:251
  8. Doctrine\Persistence\Mapping\AbstractClassMetadataFactory-&gt;getMetadataFor() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:293
  9. Doctrine\ORM\EntityManager-&gt;getClassMetadata() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/doctrine/orm/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php:45
 10. Doctrine\ORM\Repository\DefaultRepositoryFactory-&gt;getRepository() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:768
 11. Doctrine\ORM\EntityManager-&gt;getRepository() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/src/Usuario/src/Repository/UsuarioRepository.php:23
 12. Usuario\Repository\UsuarioRepository-&gt;getByLogin() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/src/Usuario/src/Middleware/LoginMiddleware.php:53
 13. Usuario\Middleware\LoginMiddleware-&gt;process() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php:37
 14. Mezzio\Middleware\LazyLoadingMiddleware-&gt;process() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/mezzio/mezzio-router/src/Route.php:85
 15. Mezzio\Router\Route-&gt;process() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/mezzio/mezzio-router/src/RouteResult.php:97
 16. Mezzio\Router\RouteResult-&gt;process() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/mezzio/mezzio-router/src/Middleware/DispatchMiddleware.php:30
 17. Mezzio\Router\Middleware\DispatchMiddleware-&gt;process() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php:37
 18. Mezzio\Middleware\LazyLoadingMiddleware-&gt;process() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/laminas/laminas-stratigility/src/Next.php:51
 19. Laminas\Stratigility\Next-&gt;handle() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/mezzio/mezzio-helpers/src/UrlHelperMiddleware.php:48
 20. Mezzio\Helper\UrlHelperMiddleware-&gt;process() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php:37
 21. Mezzio\Middleware\LazyLoadingMiddleware-&gt;process() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/laminas/laminas-stratigility/src/Next.php:51
 22. Laminas\Stratigility\Next-&gt;handle() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/mezzio/mezzio-router/src/Middleware/MethodNotAllowedMiddleware.php:56
 23. Mezzio\Router\Middleware\MethodNotAllowedMiddleware-&gt;process() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php:37
 24. Mezzio\Middleware\LazyLoadingMiddleware-&gt;process() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/laminas/laminas-stratigility/src/Next.php:51
 25. Laminas\Stratigility\Next-&gt;handle() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/mezzio/mezzio-router/src/Middleware/ImplicitOptionsMiddleware.php:72
 26. Mezzio\Router\Middleware\ImplicitOptionsMiddleware-&gt;process() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php:37
 27. Mezzio\Middleware\LazyLoadingMiddleware-&gt;process() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/laminas/laminas-stratigility/src/Next.php:51
 28. Laminas\Stratigility\Next-&gt;handle() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/mezzio/mezzio-router/src/Middleware/ImplicitHeadMiddleware.php:76
 29. Mezzio\Router\Middleware\ImplicitHeadMiddleware-&gt;process() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php:37
 30. Mezzio\Middleware\LazyLoadingMiddleware-&gt;process() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/laminas/laminas-stratigility/src/Next.php:51
 31. Laminas\Stratigility\Next-&gt;handle() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/mezzio/mezzio-router/src/Middleware/RouteMiddleware.php:50
 32. Mezzio\Router\Middleware\RouteMiddleware-&gt;process() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php:37
 33. Mezzio\Middleware\LazyLoadingMiddleware-&gt;process() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/laminas/laminas-stratigility/src/Next.php:51
 34. Laminas\Stratigility\Next-&gt;handle() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/laminas/laminas-stratigility/src/Middleware/PathMiddlewareDecorator.php:43
 35. Laminas\Stratigility\Middleware\PathMiddlewareDecorator-&gt;process() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/laminas/laminas-stratigility/src/Next.php:51
 36. Laminas\Stratigility\Next-&gt;handle() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/mezzio/mezzio-helpers/src/BodyParams/BodyParamsMiddleware.php:83
 37. Mezzio\Helper\BodyParams\BodyParamsMiddleware-&gt;process() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php:37
 38. Mezzio\Middleware\LazyLoadingMiddleware-&gt;process() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/laminas/laminas-stratigility/src/Next.php:51
 39. Laminas\Stratigility\Next-&gt;handle() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/mezzio/mezzio-helpers/src/ServerUrlMiddleware.php:36
 40. Mezzio\Helper\ServerUrlMiddleware-&gt;process() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php:37
 41. Mezzio\Middleware\LazyLoadingMiddleware-&gt;process() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/laminas/laminas-stratigility/src/Next.php:51
 42. Laminas\Stratigility\Next-&gt;handle() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/tuupola/cors-middleware/src/CorsMiddleware.php:124
 43. Tuupola\Middleware\CorsMiddleware-&gt;process() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/laminas/laminas-stratigility/src/Next.php:51
 44. Laminas\Stratigility\Next-&gt;handle() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/laminas/laminas-stratigility/src/Middleware/ErrorHandler.php:131
 45. Laminas\Stratigility\Middleware\ErrorHandler-&gt;process() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/mezzio/mezzio/src/Middleware/LazyLoadingMiddleware.php:37
 46. Mezzio\Middleware\LazyLoadingMiddleware-&gt;process() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/laminas/laminas-stratigility/src/Next.php:51
 47. Laminas\Stratigility\Next-&gt;handle() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php:76
 48. Laminas\Stratigility\MiddlewarePipe-&gt;process() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php:65
 49. Laminas\Stratigility\MiddlewarePipe-&gt;handle() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/laminas/laminas-httphandlerrunner/src/RequestHandlerRunner.php:96
 50. Laminas\HttpHandlerRunner\RequestHandlerRunner-&gt;run() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/private/vendor/mezzio/mezzio/src/Application.php:68
 51. Mezzio\Application-&gt;run() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/public/index.php:30
 52. {closure}() /mnt/arquivos/Projetos/Neocyber/NeoSchool/Backend/public/index.php:31

Also (but less important) when I try to validate the schema on cli it tells me that the enum type is not supported.

Could someone give me some help?

My actual doctrine.global.config:

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

return array(
    'doctrine' => [
        'driver'    =>  [
            'orm_default'   =>  [
                'class' => \Doctrine\Persistence\Mapping\Driver\MappingDriverChain::class,
            ]
        ],
        'connection' => [
            'orm_default' => [
                'driverClass' => \Doctrine\DBAL\Driver\PDOMySql\Driver::class,
                'charset' => 'UTF8mb4',
                'collation' => 'UTF8mb4_unicode_ci',
            ]
        ],
        'configuration' => [
            'orm_default' => [
                'result_cache' => 'custom_cache',
                'metadata_cache' => 'custom_cache',
                'query_cache' => 'custom_cache',
                'hydration_cache' => 'custom_cache',
            ]
        ],
        'cache' => [
            'custom_cache' => [
                'class' => \Common\Cache\CustomCache::class, // Because Doctrine Cache breaking changes
            ],
        ],
        'types' => [
            'enum'  => Doctrine\DBAL\Types\StringType::class
        ]
    ],
    'dependencies' => [
        'factories' => [
            'doctrine.entity_manager.orm_default' => \Roave\PsrContainerDoctrine\EntityManagerFactory::class,
        ],
    ]
);

Relevant part of ConfigProvider.php:

/**
     * Retorna configuração das Entities do doctrine
     * @return array
     */
    public function getEntities()
    {
        return array(
            'driver' => [
                'orm_default' => [
                    'drivers' => [
                        Entity\Usuario::class => 'usuario_entity',
                    ],
                ], 
                // Here I tried several possible ways and configuration structures for the driver and paths, but with no result.
                'usuario_entity' => [
                    'class' => AnnotationDriver::class,
                    'cache' =>  'custom_cache',
                    'paths' => __DIR__ . '/Entity',
                ],
            ],
        );
    }
...

If anyone can help me figure out where I'm going wrong I'll be very grateful.
I use a configuration very similar to this one in another API with Zend Expressive and with the DASPRiD/container-interop-doctrine plugin, and there it works perfectly.

But here I haven't been able to find the way yet.

Thanks in advance.

Wrong configuration example for the migrations

The full example shows how the migrations can be configured:
https://github.com/Roave/psr-container-doctrine/blob/2.2.0/example/full-config.php#L152-L158

However, I that configuration is not valid, because the AbstractFactory retrieves the configuration by a config key, which in most cases is orm_default, so instead of having this:

'migrations' => [
    'directory' => 'scripts/orm/migrations',
    'name'      => 'My DB Migrations',
    'namespace' => 'My\Migration',
    'table'     => 'migration',
    'column'    => 'version_timestamp',
],

what we would really want to have is this:

'migrations' => [
    'orm_default' => [
        'directory' => 'scripts/orm/migrations',
        'name'      => 'My DB Migrations',
        'namespace' => 'My\Migration',
        'table'     => 'migration',
        'column'    => 'version_timestamp',
    ],
],

I'm not sure if this is correct, so I'm posting it as an issue, not a PR, so we can have a discussion first.

Upgrade to doctrine-migrations v3

Given the release of Doctrine Migrations v3, is the support for the new version planned? It's such a pity, because the migrations support for psr-container-doctrine was added not a long time ago, but the version is now locked to v2. Can we do this without a BC break?

Little mistake in "aliases" example? (documentation)

Hi,

is it possible that there is a little mistake "aliases" example in README.md?

This didn't work:

'aliases' => [
     'doctrine.entity_manager.orm_default' =>  EntityManagerInterface::class, 
],

This however, works (the other way round):

'aliases' => [
    EntityManagerInterface::class => 'doctrine.entity_manager.orm_default',
],

But since I'm new to Laminas / Mezzio / Doctrine / PSR-11, it is also likely that I'm doing it wrong, so please forgive me if the mistake sits in front of the screen :-)

Kind regards

Conflict dependencies updating to doctrine orm 2.8

Hi,

My goal is to upgrade doctrine/orm to latest version 2.8.1 but a conflict for the doctrine/common appeared because

this package 2.2.0 relies on doctrine/common ^2.6 but doctrine/orm applies this constraint doctrine/common ^3.0.

Is it possible to change the constraints on this package?

Use Service factories in Doctrine MongoDB ODM module

Due to the latest license incidents in PHP-land, @alcaeus asked me to reach out to you and ask if it's ok to use parts of your service factories in the DoctrineMongoODMModule package.

Most of the factories are the same for ORM and ODM and your AbstractFactory is written quite nicely so I used them to instantiate the services there while upgrading the library to be compatible with mongodb-odm 2.0

Is it ok for you to put a license header to each file stating that it's origin or should I mention it somewhere else (LICENCE, README)?

Thanks!

DriverFactory.php incompatible with doctrine/common: "^3.0"

Hi i noticed that /src/DriverFactory.php is not compatible with doctrine/common ^3.0
since

use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\AnnotationRegistry;

are only available below version 3.0, so it seems the package.json is broken with psr-contrianer-doctrine 3.x

Multiple EntityManagers wont work due to invalid AbstractFactory

Hey there,

I tried to use this package with multiple EntityManager instances.
I realized that the EntityManagerFactory does not pass the requestedName to the factory and thus its always orm_default which is being created:

from laminas-servicemanager

if (is_string($factory) && class_exists($factory)) {
    $factory = new $factory();
    $lazyLoaded = true;
}

from AbstractFactory in this project

  /** @internal */
public function __construct(string $configKey = 'orm_default')
{
    $this->configKey = $configKey;
}

/**
 * @return mixed
 */
public function __invoke(ContainerInterface $container)
{
    return $this->createWithConfig($container, $this->configKey);
}

$requestedName is never passed the __construct consumed by __invoke.

Did I overlooked something or is this a bug?

DsnParser doesn't map scheme like before

In doctrine dbal 3, I had url starts with: mysql:// and doctrine correctly handle this connection string. But now, even with #124 I still cannot make a connection (pdo-mysql is correct right now).

Looks like missing predefined scheme mapping in DsnParser https://github.com/Roave/psr-container-doctrine/pull/124/files#diff-a0906b5aa460579706c33a67d2bed0b0b2085cf46ef55a7d7ba103cbe5cf4407R116

It will be nice to be able to confiure this map. I see two ways:

  1. Define map in config and pass to constructor.
  2. Get DsnParser from container and then I be able to make map by my own.

Document changes for 2.0

Add a few notes about BC breaks, and things to be aware of (like namespace change, but also the BC shim so old namespaces work). BC breaks so far are adding types in AbstractFactory for example. It probably makes sense to mark this @internal too. Also include any important BC breaks in #3 .

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Repository problems

These problems occurred while renovating this repository. View logs.

  • WARN: Use matchDepNames instead of matchPackageNames

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • Lock file maintenance

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

composer
composer.json
  • php ~8.2.0 || ~8.3.0
  • doctrine/common ^3.4.4
  • doctrine/dbal ^4.0.3
  • doctrine/event-manager ^2
  • doctrine/migrations ^3.7.4
  • doctrine/orm ^3.2.0
  • doctrine/persistence ^3.3.2
  • psr/cache ^2.0.0 || ^3.0.0
  • psr/container ^1.1.2 || ^2.0.2
  • doctrine/coding-standard ^12.0.0
  • phpunit/phpunit ^10.5.21
  • psalm/plugin-phpunit ^0.19.0
  • symfony/yaml ^7.1.1
  • vimeo/psalm ^5.24.0
example/composer.json
  • php ~8.2.0 || ~8.3.0
  • illuminate/container ^11.10.0
  • laminas/laminas-servicemanager ^4.1.0
  • symfony/cache ^7.1.1
github-actions
.github/workflows/coding-standards.yml
  • actions/checkout v4
  • shivammathur/setup-php 2.30.5
  • actions/cache v4
.github/workflows/composer-require-checker.yml
  • actions/checkout v4
  • shivammathur/setup-php 2.30.5
  • actions/cache v4
.github/workflows/release-on-milestone-closed-triggering-release-event.yml
  • actions/checkout v4
  • laminas/automatic-releases v1
  • laminas/automatic-releases v1
  • laminas/automatic-releases v1
  • laminas/automatic-releases v1
.github/workflows/roave-bc-check.yml
  • actions/checkout v4
  • shivammathur/setup-php 2.30.5
  • actions/cache v4
.github/workflows/static-analysis.yml
  • actions/checkout v4
  • shivammathur/setup-php 2.30.5
  • actions/cache v4
.github/workflows/test.yml
  • actions/checkout v4
  • shivammathur/setup-php 2.30.5
  • actions/cache v4

  • Check this box to trigger a request for Renovate to run again on this repository

Class 'Doctrine\Common\Cache\ArrayCache' not found with doctrine/cache 2.x upgrade

It appears doctrine/cache has stopped supporting pre-built caching implementations. This container needs to be updated to consider doctrine/cache 2.x. In the immediate, this should be locked into compatibility with doctrine/cache:^1.0.0.

I am currently using doctrine/cache 1.11.3 and can't confirm compatibility with versions previous to this.

I can also confirm that adding this version constraint locally fixed my issue.

Missing "class" config key on Laminas Mezzio

Hi!
I'm facing some initialization problems with lib.

The exception that I receive is:

ServiceNotCreatedException
Service with name "doctrine.entity_manager.orm_default" could not be created. Reason: Missing "class" config key

My global config:

return array(
    'doctrine' => [
        'driver' => [
            'orm_default' => [
                'class' => \Doctrine\ORM\Mapping\Annotation::class,
            ],
        ],
        'connection' => [
            'orm_default' => [
                'charset' => 'UTF8mb4',
                'collation' => 'UTF8mb4_unicode_ci',
            ]
        ],
        'configuration' => [
            'orm_default' => [
                'result_cache' => 'custom_cache',
                'metadata_cache' => 'custom_cache',
                'query_cache' => 'custom_cache',
                'hydration_cache' => 'custom_cache',
            ]
        ],
        'cache' => [
            'orm_default' => [
                'custom_cache' => [
                    'class' => CustomCacheProvider::class, // Because Doctrine Cache breaking changes
                ],
            ]
        ]
    ],
    'dependencies' => [
        'factories' => [
            'doctrine.entity_manager.orm_default' => \Roave\PsrContainerDoctrine\EntityManagerFactory::class,
        ],
    ]
);

Edit: With some debug i found that problem is with cache factory, maybe related with #46

It's possible to disable cache for now, while I'm in developement time?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.