api-platform: Symfony Runtime is missing

API Platform version(s) affected: x.y.z

Description

In a fresh install of api-platform, can’t run docker compose up

20231014) 13.2.1 20231014, 64-bit
api-platform-database-1  | 2023-12-29 13:10:01.684 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
api-platform-database-1  | 2023-12-29 13:10:01.684 UTC [1] LOG:  listening on IPv6 address "::", port 5432
api-platform-database-1  | 2023-12-29 13:10:01.686 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
api-platform-database-1  | 2023-12-29 13:10:01.690 UTC [24] LOG:  database system was shut down at 2023-12-29 13:09:17 UTC
api-platform-database-1  | 2023-12-29 13:10:01.695 UTC [1] LOG:  database system is ready to accept connections
api-platform-php-1       | Waiting for database to be ready...
api-platform-php-1       | The database is not up or not reachable:
api-platform-php-1       | PHP Fatal error:  Uncaught LogicException: Symfony Runtime is missing. Try running "composer require symfony/runtime". in /app/bin/console:8

How to reproduce

1.just download or clone the repo. 2. docker compose build --no-cache 3. docker compose up --wait Possible Solution

I cant’t see the problem. Don’t have apache or nginx or pgsql Additional Context

O.S : Linux Mint Api Platform Version: 3.2.10 image

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 5
  • Comments: 16 (3 by maintainers)

Most upvoted comments

I tried ENV COMPOSER_ALLOW_SUPERUSER=1 in my DockerFile and it works like a charm.

Composer documentation :

COMPOSER_ALLOW_SUPERUSER# If set to 1, this env disables the warning about running commands as root/super user. It also disables automatic clearing of sudo sessions, so you should really only set this if you use Composer as a super user at all times like in docker containers.

Probably explained by this composer issue.

Same issue encountered on project using api-platform v3.1 and symfony v6.3

It seems like the command composer install --no-progress --no-scripts --optimize-autoloader --prefer-dist --no-interaction executed, when building the production image, don’t generate the file autoload_runtime.php required by the console.

composer require symfony/runtime generate the file.

From the symfony documentation :

If you use the Composer --no-plugins option, the autoload_runtime.php file won’t be created.

If you use the Composer --no-scripts option, make sure your Composer version is >=2.1.3; otherwise the autoload_runtime.php file won’t be created.

Here is the log of our gitlab CI :

#35 [stage-1 24/25] RUN composer install --no-progress --no-scripts --optimize-autoloader --prefer-dist --no-interaction
#35 0.320 Composer plugins have been disabled for safety in this non-interactive session. Set COMPOSER_ALLOW_SUPERUSER=1 if you want to allow plugins to run as root/super user.

Maybe it is the root cause of this issue.

I just met the same issue on FrankenPHP, it’s related to the vendor volume, somehow the composer install in the entrypoint didn’t proc

I “fixed” it by simply enabling this https://github.com/api-platform/api-platform/blob/main/compose.override.yaml#L14

Hello.

I encountered this problem by installing version 4.1.0 on Wsl 2.

I wanted to report that the solution proposed by @Tim-Alpha worked.

Thank you very much.

I got this same problem because I had this in my composer.json:

    "config": {
        "allow-plugins": {
            "symfony/runtime": false
        }
    }

Allowing the plugin fixed it, then the autoload_runtime.php was generated like @Bryce-Colton said. Thanks for the hints.

@Bryce-Colton I have set ENV COMPOSER_ALLOW_SUPERUSER=1 in my DockerFile but i am still facing the issue.