Open krajcikondra opened 2 years ago
Having the same problem, although I am running ppm inside a Docker container and symfony 6.1.
Command:
/ppm/vendor/bin/ppm start \ --workers=1 \ --host=0.0.0.0 \ --debug 1 \ --socket-path=/tmp \ --static-directory=public/ \ --pidfile=/ppm/ppm.pid
When running the same command from a local console, symfony parses the .env (or .env.local.php) file correctly and the env vars are listed in webprofiler (in Server Params).
When running in docker, the webprofiler shows "no data". I have to pass all variables as docker environment variables in docker-compose file. .env and .env.local.php are bind-mounted into the container (the whole project directory).
In docker:
In debian bash:
composer.json for ppm:
{ "require": { "php-pm/httpkernel-adapter": "dev-master", "php-pm/php-pm": "dev-master" } }
Dockerfile: `FROM php:8.1-alpine AS php
ENV OPCACHE_ENABLE="On" ENV PHPPM_WORKERS=1 ENV APP_ENV="prod"
ENV STATIC_DIR="public" ENV PPM_DEBUG=0
RUN apk add \ icu-dev \ icu-data-full \ libpq-dev \ bash
RUN docker-php-ext-configure intl \ && docker-php-ext-install \ pdo_pgsql \ opcache \ intl \ pcntl
COPY build/php/config/* /usr/local/etc/php/conf.d/
RUN mkdir -p /ppm
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer COPY build/php/ppm/composer.json build/php/ppm/composer.lock /ppm/
WORKDIR /ppm
RUN composer install
RUN mkdir -p /var/www
WORKDIR /var/www
CMD /ppm/vendor/bin/ppm start \ --bootstrap=symfony \ --bridge=HttpKernel \ --workers=${PHPPM_WORKERS} \ --host=0.0.0.0 \ --debug ${PPM_DEBUG} \ --socket-path=/tmp \ --static-directory=${STATIC_DIR}/ \ --pidfile=/ppm/ppm.pid
EXPOSE 8080`
The problem is related to how .env files are parsed in symfony: When APP_ENV is already set, no .env file is parsed. The symfony bootstrap for php-pm does the same, see PHPPM\Bootstraps::getApplication()
I created a pull request for this bug: https://github.com/php-pm/php-pm-httpkernel/pull/186
I recommand to include your env file into the docker-compose service like described here: https://docs.docker.com/compose/environment-variables/set-environment-variables/#use-the-env_file-attribute
When I run php pm with test environment
vendor/bin/ppm start --config=ppm.json --app-env=test
I got following exception:
My .env.test file:
Do I start ppm server properly? I use symfony 5.2