phoenix icon indicating copy to clipboard operation
phoenix copied to clipboard

Error thrown while running command "doctrine:database:create --if-not-exists". Message: "Class "Doctrine\DBAL\Schema\LegacySchemaManagerFactory" not found"

Open 4d4ch4u32 opened this issue 4 months ago • 5 comments

Bug Report

The following error occurs when I try to start a docker container with the doctrine packages below:

php.INFO: User Deprecated: Class "Doctrine\ORM\Proxy\Autoloader" is deprecated. Use native lazy objects instead. (Autoloader.php:74 called by DoctrineBundle.php:130, https://github.com/doctrine/orm/pull/12005, package doctrine/orm) {"exception":"[object] (ErrorException(code: 0): User Deprecated: Class \"Doctrine\\ORM\\Proxy\\Autoloader\" is deprecated. Use native lazy objects instead. (Autoloader.php:74 called by DoctrineBundle.php:130, https://github.com/doctrine/orm/pull/12005, package doctrine/orm) at /var/www/html/vendor/doctrine/deprecations/src/Deprecation.php:208)"} []
console.CRITICAL: Error thrown while running command "doctrine:database:create --if-not-exists". Message: "Class "Doctrine\DBAL\Schema\LegacySchemaManagerFactory" not found" {"exception":"[object] (Error(code: 0): Class \"Doctrine\\DBAL\\Schema\\LegacySchemaManagerFactory\" not found at /var/www/html/var/cache/prod/Container2xcgV4Y/App_KernelProdContainer.php:231)","command":"doctrine:database:create --if-not-exists","message":"Class \"Doctrine\\DBAL\\Schema\\LegacySchemaManagerFactory\" not found"} []
Error thrown while running command "doctrine:database:create --if-not-exists". Message: "Class "Doctrine\DBAL\Schema\LegacySchemaManagerFactory" not found" ["exception" => Error { …},"command" => "doctrine:database:create --if-not-exists","message" => "Class "Doctrine\DBAL\Schema\LegacySchemaManagerFactory" not found"]
console.DEBUG: Command "doctrine:database:create --if-not-exists" exited with code "1" {"command":"doctrine:database:create --if-not-exists","code":1} []
[2025-08-29T12:32:59.921175+00:00] php.CRITICAL: Uncaught Error: Class "Doctrine\DBAL\Schema\LegacySchemaManagerFactory" not found {"exception":"[object] (Error(code: 0): Class \"Doctrine\\DBAL\\Schema\\LegacySchemaManagerFactory\" not found at /var/www/html/var/cache/prod/Container2xcgV4Y/App_KernelProdContainer.php:231)"} []

Installed doctrine packages:

doctrine/annotations                           2.0.2     Docblock Annotations Parser
doctrine/collections                           2.3.0     PHP Doctrine Collections library that adds additional functionality on top of PHP arrays.
doctrine/data-fixtures                         2.1.0     Data Fixtures for all Doctrine Object Managers
doctrine/dbal                                  4.3.2     Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.
doctrine/deprecations                          1.1.5     A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively fo...
doctrine/doctrine-bundle                       2.15.1    Symfony DoctrineBundle
doctrine/doctrine-fixtures-bundle              4.1.0     Symfony DoctrineFixturesBundle
doctrine/doctrine-migrations-bundle            3.4.2     Symfony DoctrineMigrationsBundle
doctrine/event-manager                         2.0.1     The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doctrine projects.
doctrine/inflector                             2.1.0     PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercase and singular/plural f...
doctrine/instantiator                          2.0.0     A small, lightweight utility to instantiate objects in PHP without invoking their constructors
doctrine/lexer                                 3.0.1     PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.
doctrine/migrations                            3.9.4     PHP Doctrine Migrations project offer additional functionality on top of the database abstraction layer (DBAL) for versioning your d...
doctrine/orm                                   3.5.2     Object-Relational-Mapper for PHP
doctrine/persistence                           4.1.0     The Doctrine Persistence project is a set of shared interfaces and functionality that the different Doctrine object mappers share.
doctrine/sql-formatter                         1.5.2     a PHP SQL highlighting library

4d4ch4u32 avatar Aug 29 '25 12:08 4d4ch4u32

Does the issue persist if you clean the Symfony cache before?

xabbuh avatar Aug 29 '25 13:08 xabbuh

This issue occurs when a freshly built Docker container starts in a pipeline. There is no cache at this stage.

4d4ch4u32 avatar Aug 29 '25 14:08 4d4ch4u32

Can you create a small example application that allows to reproduce your issue?

xabbuh avatar Aug 29 '25 14:08 xabbuh

try running the command in verbose mode so that it displays a stack trace (assuming you have access to the command output, not just to logs)

stof avatar Aug 29 '25 15:08 stof

This is not reproducible. The error occurs when I start a Docker Compose configuration in a GitLab pipeline.

However, if the database (mysql) service starts at first separately from the others, wait 30 seconds with a subsequent sleep and then start the remaining services, it works.

4d4ch4u32 avatar Sep 16 '25 10:09 4d4ch4u32