Using Docker to Host Zencart (PHP 7.3.33) - php

I have set up Docker Compose to build a PHP environment hosted by Nginx in order to run a Zencart site. I have viewed a few different walkthroughs and forums, and have gotten very close to having a functional implementation.
For some reason, Zencart fails to recognize the presence of the Zip and GD (GD Imaging) modules, despite them being enabled in the parser. I suspect there may be some sort of incompatibility in the version of the modules used versus the version of PHP installed.
Zencart claims to only support PHP versions before 7.4. I do not know if the modules installed are also dependent on the version of PHP used, or if they may be intended for a later version.
I have attached images of the PHP configuration, along with the requirements screen for the Zencart instance I am running. Zencart's requirements are nearly met, save for GD and Zip, as indicated. Also attached are the Docker Compose YAML file, the PHP docker file, and the NGINX docker file.
Any help that can be given in deciphering this mystery would be greatly appreciated.
docker-compose.yml
version: '3'
services:
php:
image: harbor.my-host.hosting/express/php:${RELEASE_TAG:-edge}
build:
context: .
dockerfile: dockerfiles/php.dockerfile
args:
- UID=${UID:-1000}
- GID=${GID:-1000}
# environment:
# - WIDGET_DB_HOST=${WIDGET_DB_HOST}
# - WIDGET_DB_UNAME=${WIDGET_DB_UNAME}
# - WIDGET_DB_PWD=${WIDGET_DB_PWD}
# - WIDGET_DB_NAME=${WIDGET_DB_NAME}
# - QUEUE_DB_HOST=${QUEUE_DB_HOST}
# - QUEUE_DB_UNAME=${QUEUE_DB_UNAME}
# - QUEUE_DB_PWD=${QUEUE_DB_PWD}
# - QUEUE_DB_NAME=${QUEUE_DB_NAME}
volumes:
- ./src:/var/www/html:consistent
networks:
- php-app
nginx:
image: harbor.my-host.hosting/express/nginx:${RELEASE_TAG:-edge}
build:
context: .
dockerfile: dockerfiles/nginx.dockerfile
args:
- UID=${UID:-1000}
- GID=${GID:-1000}
volumes:
- ./src:/var/www/html:consistent
ports:
- 8080:80
depends_on:
- php
networks:
- php-app
networks:
php-app:
external: false
php.dockerfile
FROM php:7.3-fpm-alpine
ARG UID
ARG GID
ENV UID=${UID}
ENV GID=${GID}
RUN apk add --no-cache --virtual \
build-essentials \
mysql-client \
icu-dev \
icu-libs \
zlib-dev \
g++ \
make \
automake \
autoconf \
libzip-dev \
freetype \
libjpeg-turbo-dev \
libpng-dev \
zip \
unzip
RUN docker-php-ext-install mysqli && \
docker-php-ext-install pdo_mysql && \
docker-php-ext-install exif && \
docker-php-ext-install mbstring && \
docker-php-ext-install zip && \
docker-php-ext-install gd && \
docker-php-ext-configure gd && \
docker-php-ext-enable gd && \
docker-php-ext-enable exif && \
docker-php-ext-enable zip && \
apk del build-essentials && rm -rf /usr/src/php*
WORKDIR /var/www/html
# MacOS staff group's gid is 20, so is the dialout group in alpine linux. We're not using it, let's just remove it.
RUN delgroup dialout
RUN addgroup -g ${GID} --system phpapp
RUN adduser -G phpapp --system -D -s /bin/sh -u ${UID} phpapp
RUN sed -i "s/user = www-data/user = phpapp/g" /usr/local/etc/php-fpm.d/www.conf
RUN sed -i "s/group = www-data/group = phpapp/g" /usr/local/etc/php-fpm.d/www.conf
RUN echo "php_admin_flag[log_errors] = true" >> /usr/local/etc/php-fpm.d/www.conf
RUN echo "php_admin_flag[display_errors] = off" >> /usr/local/etc/php-fpm.d/www.conf
COPY src /var/www/html
RUN chown -R phpapp /var/www/html
CMD ["php", "artisan", "key:generate"]
CMD ["php", "artisan", "config:cache"]
CMD ["php-fpm", "-y", "/usr/local/etc/php-fpm.conf", "-R"]
nginx.dockerfile
FROM nginx:stable-alpine
ARG UID
ARG GID
ENV UID=${UID}
ENV GID=${GID}
# MacOS staff group's gid is 20, so is the dialout group in alpine linux. We're not using it, let's just remove it.
RUN delgroup dialout
RUN addgroup -g ${GID} --system phpapp
RUN adduser -G phpapp --system -D -s /bin/sh -u ${UID} phpapp
RUN sed -i "s/user nginx/user phpapp/g" /etc/nginx/nginx.conf
ADD ./dockerfiles/nginx/default.conf /etc/nginx/conf.d/
COPY src /var/www/html
RUN chown -R phpapp /var/www/html

Related

Laravel request/response time very slow on Docker Laravel 8

Does anyone have any idea why the request time of my Laravel project is running very slow? I'm running the project on Docker and I use a Dockerfile and docker-compose.yml. I'm also using nginx
I have tried multiple things like Eager loading and artisan optimize but none of those seems to work.
I'm running this on a laptop with an i7-9750H and 16gb RAM.
This what my debugbar says:
Dockerfile in a folder named 'php':
FROM php:8.0-fpm-alpine
RUN apk add shadow && usermod -u 1000 www-data && groupmod -g 1000 www-data
RUN chmod 777 /dev/stdout /dev/stderr
RUN apk --update add wget \
curl \
git \
grep \
build-base \
libmcrypt-dev \
libxml2-dev \
zlib-dev \
autoconf \
cyrus-sasl-dev \
libgsasl-dev \
composer \
supervisor \
libpng-dev \
freetype-dev \
libjpeg-turbo-dev \
libjpeg-turbo-utils \
openssh \
htop \
nano \
ghostscript \
imagemagick-dev \
libzip-dev \
wkhtmltopdf \
jpegoptim \
optipng \
pngquant \
pngcrush \
gifsicle \
bash
RUN apk add --update --no-cache graphviz font-bitstream-type1
RUN echo '* * * * * php /var/www/html/artisan schedule:run' | crontab -u www-data -
RUN rm -rf /var/spool/cron/crontabs/root
RUN docker-php-ext-install mysqli pdo pdo_mysql tokenizer xml zip exif
RUN pecl channel-update pecl.php.net \
&& pecl install redis \
&& rm -rf /tmp/pear \
&& docker-php-ext-enable redis \
&& docker-php-ext-install gd \
&& docker-php-ext-install -j$(nproc) iconv \
&& docker-php-ext-configure gd \
&& docker-php-ext-install -j$(nproc) gd \
&& docker-php-ext-install bcmath
# install imagick
# use github version for now until release from https://pecl.php.net/get/imagick is ready for PHP 8
RUN mkdir -p /usr/src/php/ext/imagick \
&& curl -fsSL https://github.com/Imagick/imagick/archive/06116aa24b76edaf6b1693198f79e6c295eda8a9.tar.gz | tar xvz -C "/usr/src/php/ext/imagick" --strip 1 \
&& docker-php-ext-install imagick
RUN rm /var/cache/apk/* && \
mkdir -p /var/www && \
chown www-data:www-data /var/www -R
CMD ["/usr/bin/supervisord", "-n", "-c", "/etc/supervisord.conf"]
USER www-data
RUN composer global require laravel/envoy
ENV PATH "$PATH:/home/www-data/.composer/vendor/bin"
Dockerfile inside folder named 'nginx':
FROM nginx:alpine
docker-compose.yml
version: "3"
services:
php:
volumes:
- './src/:/var/www/html'
- './.docker/php/supervisor.conf:/etc/supervisord.conf'
tty: true
build:
context: .
dockerfile: .docker/php/Dockerfile
links:
- "db:database"
- "redis:redis"
networks:
internal:
traefik:
nginx:
image: nginx:alpine
volumes:
- './src:/var/www/html'
- './.docker/nginx/nginx/conf.d/:/etc/nginx/conf.d/'
- './.docker/nginx/nginx/nginx.conf:/etc/nginx/nginx.conf'
labels:
traefik.backend: domain.test
traefik.frontend.rule: "Host:library.test"
traefik.docker.network: traefik
traefik.port: 80
networks:
internal:
traefik:
depends_on:
- php
db:
image: mysql/mysql-server:latest
environment:
MYSQL_DATABASE: 'library'
MYSQL_USER: 'amin'
MYSQL_PASSWORD: 'secret'
MYSQL_ROOT_PASSWORD: 'secret'
DEFAULT_AUTHENTICATION_PLUGIN: 'mysql_native_password'
volumes:
- mysql:/var/lib/mysql:rw
- './database:/var/data'
networks:
- internal
ports:
- "3306:3306"
# Cache server
redis:
image: redis:4-alpine
volumes:
- redis:/data:rw
networks:
internal:
volumes:
mysql:
driver: "local"
redis:
driver: "local"
networks:
traefik:
external: true
internal:
external: false
That's not slow.
20MB in 1.7s is about 12MB/s, with overheads that's pretty quick.
The route you're hitting is returning heaps of data, probably more than you expect, and that's why it looks like it's running slow.

ENV caching issue on local development (PHP-FPM, NGINX & LARAVEL)

We are running a laravel application by docker. We are creating a docker container using PHP-FPM (php:7.0-fpm official image) & NGINX. We use a common .env file for both docker and laravel applications.
we up & running our application by - docker-compose --env-file=./.env -f docker-compose.yml up -d
But the problem is when we change our .env file, the application not detected the change. We want to get every .env file change without re-creating the container.
Dockerfile -
FROM php:7.0-fpm
# PHP_CPPFLAGS are used by the docker-php-ext-* scripts
ENV PHP_CPPFLAGS="$PHP_CPPFLAGS -std=c++11"
# Install dependencies
RUN apt-get update && apt-get install -y \
nginx \
libpng-dev \
zlib1g-dev \
libsasl2-dev \
libssl-dev \
libjpeg62-turbo-dev \
libfreetype6-dev \
libpng-dev \
libxpm-dev \
libvpx-dev \
libxml2-dev \
libicu-dev \
git
# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Install extensions
RUN docker-php-ext-configure gd --with-gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-png-dir=/usr/include/
RUN docker-php-ext-configure intl
RUN docker-php-ext-install -j$(nproc) pdo_mysql mbstring zip calendar soap gd intl
# Install mongodb extension
RUN pecl install mongodb-1.4.4 \
&& echo "extension=mongodb.so" > /usr/local/etc/php/conf.d/mongo.ini
# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer --version=1.8.6
RUN composer global require hirak/prestissimo
COPY entrypoint.sh /etc/entrypoint.sh
RUN chmod +x /etc/entrypoint.sh
RUN usermod -u 1000 www-data
# Set working directory
WORKDIR /var/www
EXPOSE 80 443
Docker Compose -
version: '3.5'
services:
api-service:
environment:
SERVICE_NAME: app
VIRTUAL_HOST: ${API_DOMAIN}
working_dir: /var/www
entrypoint: /etc/entrypoint.sh
volumes:
- ../../:/var/www
- ../nginx/conf.d/nginx-local.conf:/etc/nginx/sites-enabled/default
- ../php/local.ini:/usr/local/etc/php/conf.d/local.ini
- ../php/memory_limit.ini:/usr/local/etc/php/conf.d/memory_limit.ini
- ../php/php.ini:/usr/local/etc/php/conf.d/php.override.ini
- ../php/www.conf:/usr/local/etc/php-fpm.d/www.conf
ports:
- ${PORT}:80
networks:
api-service-network:
external:
name: ${EXTERNAL_NETWORK}
entrypoint -
#!/usr/bin/env bash
service nginx start
php-fpm
So is it possible to reload ENV (on local development by PHP-FPM) without recreating the container.
Try using env_file in docker-compose
Maybe can help you

Need help in executing powershell commands in dockerized laravel

I want to access vsphere config info from powercli script to laravel. But I do not know how to make them work together in docker. Whatever I do, the error is similar to this - The command "'pwsh' '-v'" failed. Exit Code: 127(Command not found) Working directory: /var/www/public Output: ================ Error Output: ================ sh: 1: exec: pwsh: not found
As a last resort, I am here.
docker-compose.yml:
version: '3'
services:
#PHP Service
app:
build:
context: .
dockerfile: Dockerfile
image: vapp
container_name: app
restart: unless-stopped
tty: true
environment:
SERVICE_NAME: app
SERVICE_TAGS: dev
working_dir: /var/www
volumes:
- ./:/var/www
- ./php/local.ini:/usr/local/etc/php/conf.d/local.ini
networks:
- app-network
#Nginx Service
webserver:
image: nginx:alpine
container_name: webserver
restart: unless-stopped
tty: true
ports:
- "80:80"
- "443:443"
volumes:
- ./:/var/www
- ./nginx/conf.d/:/etc/nginx/conf.d/
networks:
- app-network
#MySQL Service
db:
image: mysql:5.7.22
container_name: db
restart: unless-stopped
tty: true
ports:
- "3306:3306"
environment:
MYSQL_DATABASE: vapp
MYSQL_ROOT_PASSWORD: vapp
SERVICE_TAGS: dev
SERVICE_NAME: mysql
TZ: Asia/Kolkata
volumes:
- dbdata:/var/lib/mysql/
- ./mysql/my.cnf:/etc/mysql/my.cnf
- ./mysql:/var/lib/mysql-files/
networks:
- app-network
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: phpMyAdmin
restart: always
ports:
- "8080:80"
environment:
MYSQL_ROOT_PASSWORD: vapp
PMA_HOST: db
external_links:
- mariadb:mariadb
volumes:
- "./phpmyadmin/sessions:/sessions"
networks:
- app-network
#Docker Networks
networks:
app-network:
driver: bridge
#Volumes
volumes:
dbdata:
driver: local
Dockerfile
FROM mcr.microsoft.com/powershell:latest
WORKDIR ./
FROM php:7.4-fpm
# Copy composer.lock and composer.json
COPY composer.lock composer.json /var/www/
# Set working directory
WORKDIR /var/www
# Install dependencies
RUN apt-get update && apt-get install -y \
build-essential \
libpng-dev \
libjpeg62-turbo-dev \
libfreetype6-dev \
libonig-dev \
locales \
libzip-dev \
zip \
jpegoptim optipng pngquant gifsicle \
vim \
unzip \
git \
curl
RUN snap install powershell --classic
# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Install extensions
RUN docker-php-ext-install pdo_mysql mbstring zip exif pcntl mysqli
RUN docker-php-ext-configure gd --enable-gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/
RUN docker-php-ext-install gd
RUN docker-php-ext-enable mysqli
# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Add user for laravel application
RUN groupadd -g 1000 www
RUN useradd -u 1000 -ms /bin/bash -g www www
# Copy existing application directory contents
COPY . /var/www
# Copy existing application directory permissions
COPY --chown=www:www . /var/www
# Change current user to www
USER www
# Expose port 9000 and start php-fpm server
EXPOSE 9000
CMD ["php-fpm"]
Controller:
//$process = new Process(['ls', '-lsa']); #This works but next one do not
$process = new Process(['pwsh', '-v']);
$process->run();
// executes after the command finishes
if (!$process->isSuccessful()) {
throw new ProcessFailedException($process);
}
echo $process->getOutput();
I know how the Process() method works. Above code fails.
I need help on making powershell and laravel work together in docker.
Is there anything wrong with docker configuration or the controller code in accessing powershell.
You are using multistage build in Dockerfile. It can copy artifacts, but you don't copy anything. So pwsh app doesn't copy to PHP image (to the second stage).
You could remove first stage (FROM mcr.microsoft.com/powershell:latest) and install properly Powershell inside PHP image.
For example:
RUN apt-get update && apt-get install -y \
wget
RUN wget https://packages.microsoft.com/config/debian/10/packages-microsoft-prod.deb && \
dpkg -i packages-microsoft-prod.deb
RUN apt-get update && apt-get install -y \
powershell
PHP image use Debian 10, so here is the instruction: https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-linux?view=powershell-7.1#debian-10
Check pwsh inside container first:
docker exec -it app bash
pwsh
Thanks to #konstantin-bogomolov
The reason was the incorrect docker file. Powershell was not properly installed in container.
For those who stop by, Working dockerfile is below.
FROM php:7.4-fpm
# Copy composer.lock and composer.json
COPY composer.lock composer.json /var/www/
# Set working directory
WORKDIR /var/www
# Install dependencies
RUN apt-get update && apt-get install -y \
build-essential \
libpng-dev \
libjpeg62-turbo-dev \
libfreetype6-dev \
libonig-dev \
locales \
libzip-dev \
zip \
jpegoptim optipng pngquant gifsicle \
vim \
unzip \
git \
curl \
wget \
apt-utils
# Download the Microsoft repository GPG keys
RUN wget https://packages.microsoft.com/config/debian/10/packages-microsoft-prod.deb
# Register the Microsoft repository GPG keys
RUN dpkg -i packages-microsoft-prod.deb
# Update the list of products
RUN apt-get update
# Install PowerShell
RUN apt-get install -y powershell
# Start PowerShell
RUN pwsh
# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Install extensions
RUN docker-php-ext-install pdo_mysql mbstring zip exif pcntl mysqli
RUN docker-php-ext-configure gd --enable-gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/
RUN docker-php-ext-install gd
RUN docker-php-ext-enable mysqli
# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Add user for laravel application
RUN groupadd -g 1000 www
RUN useradd -u 1000 -ms /bin/bash -g www www
# Copy existing application directory contents
COPY . /var/www
# Copy existing application directory permissions
COPY --chown=www:www . /var/www
# Change current user to www
USER www
# Expose port 9000 and start php-fpm server
EXPOSE 9000
CMD ["php-fpm"]

Error when trying to up docker containers

I'm on this issue since 2 days, trying a lot of solutions found on internet but no one resolved my case... I'm frustrated, I hope someone could help me.
I'm on Linux, and I don't really understand anything with server ports, hosts, etc.
It seems that this project uses API Platform, I don't know if it could help or not.
I can't figure out how to launch this project I just received. I have an issue when launching containers (docker-compose up) :
Error thrown while running command "doctrine:schema:update -f". Message: "An exception occurred in driver: SQLSTATE[08006] [7] could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
php_1 | TCP/IP connections on port 5432?
php_1 | could not connect to server: Address not available
php_1 | Is the server running on host "localhost" (::1) and accepting
php_1 | TCP/IP connections on port 5432?"
It seems that the container can't communicate with the DB container. But I don't know exactly what to do to solve this.
There is several containers in the docker-composer.yml :
version: '3'
services:
php:
build:
context: ./api
depends_on:
- db
env_file:
- ./api/.env
# Comment out these volumes in production
volumes:
- ./api:/srv/api:rw,cached
# If you develop on Linux, comment out the following volumes to just use bind-mounted project directory from host
- /srv/api/var/
- /srv/api/var/cache/
- /srv/api/var/logs/
- /srv/api/var/sessions/
api:
build:
context: ./api
dockerfile: ./Dockerfile.nginx
depends_on:
- php
ports:
- "8080:80"
volumes:
- ./api/public:/srv/api/public:ro
cache-proxy:
build:
context: ./api
dockerfile: ./Dockerfile.varnish
depends_on:
- api
# Comment out this volume in production
volumes:
- ./api/docker/varnish/conf:/etc/varnish:ro
ports:
- "8081:80"
db:
# In production, you may want to use a managed database service
image: postgres:9.6-alpine
environment:
- POSTGRES_DB=api
- POSTGRES_USER=api-platform
# You should definitely change the password in production
- POSTGRES_PASSWORD=!ChangeMe!
volumes:
- db-data:/var/lib/postgresql/data:rw
# You may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data!
# - ./docker/db/data:/var/lib/postgresql/data:rw
ports:
- "5432:5432"
client:
# Use a static website hosting service in production
# See https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#deployment
build:
context: ./client
dockerfile: ./Dockerfile
env_file:
- ./client/.env
volumes:
- ./client:/usr/src/client:rw,cached
- /usr/src/client/node_modules
ports:
- "80:3000"
h2-proxy:
# Don't use this proxy in prod
build:
context: ./h2-proxy
dockerfile: ./Dockerfile
depends_on:
- client
- api
- cache-proxy
ports:
- "443:443"
- "444:444"
- "8443:8443"
- "8444:8444"
volumes:
db-data: {}
Dockerfile :
ARG PHP_VERSION=7.2
ARG ALPINE_VERSION=3.7
FROM php:${PHP_VERSION}-fpm-alpine${ALPINE_VERSION}
RUN apk add --no-cache \
git
ARG APCU_VERSION=5.1.11
RUN set -xe \
&& apk add --no-cache --virtual .build-deps \
$PHPIZE_DEPS \
icu-dev \
postgresql-dev \
zlib-dev \
&& docker-php-ext-install -j$(nproc) \
intl \
pdo_pgsql \
zip \
&& pecl install \
apcu-${APCU_VERSION} \
&& docker-php-ext-enable --ini-name 20-apcu.ini apcu \
&& docker-php-ext-enable --ini-name 05-opcache.ini opcache \
&& runDeps="$( \
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \
| tr ',' '\n' \
| sort -u \
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
)" \
&& apk add --no-cache --virtual .api-phpexts-rundeps $runDeps \
&& apk del .build-deps
RUN apk add --no-cache freetype libpng libjpeg-turbo freetype-dev libpng-dev libjpeg-turbo-dev && \
docker-php-ext-configure gd \
--with-gd \
--with-freetype-dir=/usr/include/ \
--with-png-dir=/usr/include/ \
--with-jpeg-dir=/usr/include/ && \
NPROC=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) && \
docker-php-ext-install -j${NPROC} gd exif && \
apk del --no-cache freetype-dev libpng-dev libjpeg-turbo-dev
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
COPY docker/php/php.ini /usr/local/etc/php/php.ini
# https://getcomposer.org/doc/03-cli.md#composer-allow-superuser
ENV COMPOSER_ALLOW_SUPERUSER 1
RUN composer global require "hirak/prestissimo:^0.3" --prefer-dist --no-progress --no-suggest --classmap-authoritative
RUN apk add --no-cache ffmpeg
WORKDIR /srv/api
# Prevent Symfony Flex from generating a project ID at build time
ARG SYMFONY_SKIP_REGISTRATION=1
# Prevent the reinstallation of vendors at every changes in the source code
COPY composer.json composer.lock ./
RUN composer install --prefer-dist --no-dev --no-autoloader --no-scripts --no-progress --no-suggest \
&& composer clear-cache
COPY . ./
RUN mkdir -p var/cache var/logs var/sessions \
&& composer dump-autoload --classmap-authoritative --no-dev \
&& chown -R www-data var
COPY docker/php/docker-entrypoint.sh /usr/local/bin/docker-entrypoint
RUN chmod +x /usr/local/bin/docker-entrypoint
ENTRYPOINT ["docker-entrypoint"]
CMD ["php-fpm"]
.env file :
APP_ENV=dev
APP_SECRET=!ChangeMe!
TRUSTED_PROXIES=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
TRUSTED_HOSTS=localhost,api
DATABASE_URL=pgsql://api-platform:!ChangeMe!#localhost/api
CORS_ALLOW_ORIGIN=^https?://localhost:?[0-9]*$
VARNISH_URL=http://cache-proxy
JWT_PRIVATE_KEY_PATH=config/jwt/private.pem
JWT_PUBLIC_KEY_PATH=config/jwt/public.pem
JWT_PASSPHRASE=symfony
JWT_TOKEN_TTL=null
MAILER_URL=gmail://email:password#localhost?
MAILER_FROM=user#example.com
CLIENT_MAGIC_LINK_URL=https://localhost/login
FACEBOOK_CLIENT_ID=433898047056774
FACEBOOK_CLIENT_SECRET=90ac80e435405a2ffeaab8a242981152
AUTH_API_KEY=123456789
ADMIN_PWD=$2y$13$vqd7AMd0A5eetDT00qLd2OkGG8T9UJ1gLsD2huOhk3iRwGCBqR3iu
I don't know if you guys needs something more. Just tell me what you need.
Thanks a lot...
You have to use the db as the database host, not localhost in the DATABASE_URL application env.

How to emulate console.log in PHP code, using docker running on localhost

I am making a Laravel/Reactjs app using using Docker. Coding in reactjs, I use console.log alot to debug, but I cannot find anything similar for debugging my PHP code. Suppose I in a PHP file want to check that my id variable is what I think it is, I would like to do the following (Auth::user() returns a user which has an id)
function somePHPfunction {
$user = Auth::user();
$id = $user->id;
console.log($id);
}
which of course doesn't work.
I am using vscode as my editor, and I have tried setting up the extension PHP Debug with Xdebug, but I can't get it to work, which I think might be due to how docker works. I have tried the following guide, but could not make that work either (and it's for mac, I'm using linux).
I have also tried running different scripts (some examples can be found here), but none of them works in code as mentioned earlier.
Below I am posting my docker file, my docker-compose.yaml file and my .env file (the project is made in Laravel).
dockerfile
FROM php:7.2-apache
RUN a2enmod rewrite
RUN rm /bin/sh && ln -s /bin/bash /bin/sh && \
apt-get update && apt-get install --no-install-recommends -y \
libjpeg-dev \
libpng-dev \
libpq-dev \
curl \
wget \
vim \
git \
unzip \
mysql-client \
;
RUN docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \
docker-php-ext-install -j "$(nproc)" \
gd \
opcache \
pdo_mysql \
pdo_pgsql \
zip \
;
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
WORKDIR /var/www/html
RUN curl -sS https://getcomposer.org/installer | php && \
mv composer.phar /usr/local/bin/composer && \
ln -s /root/.composer/vendor/bin/drush /usr/local/bin/drush
COPY scan-apache.conf /etc/apache2/sites-enabled/scan-apache.conf
docker-compose.yaml
version: '3.3'
services:
app:
image: image
build: .
container_name: container
env_file:
- .env
ports:
- "4321:80"
volumes:
- .:/var/www/html
depends_on:
- mysql
mysql:
image: mysql/mysql-server:5.7
# build: ./docker/mysql
hostname: mysql
container_name: scan-db
env_file:
- .env
volumes:
- mysql-data-scan-redcap:/var/lib/mysql
volumes:
mysql-data-scan-redcap:
networks:
default:
external:
name: webproxy
I am hoping for a method which can do the same as console.log does in javascript, so I can see what's going on at runtime.

Categories