Dorokhov.codes

01. Development process

To start developing PHP applications, you can take my docker-compose.yml:

version: '2.4'
services:
  app:
    container_name: php.app
    build: .
    ports:
      - "80:80"
    volumes:
      - .:/var/www/html

If you need xDebug and Composer:

FROM php:8.2-apache

# A lot of libraries requires zip
RUN apt-get update && apt-get install zip -y

# Use the default production configuration
RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"

# Copy the "install-php-extensions" script from the "mlocati/php-extension-installer" Docker image:
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/

RUN install-php-extensions xdebug

# If we want to run Composer as root:
ENV COMPOSER_ALLOW_SUPERUSER 1 

# copy the Composer PHAR from the Composer image into the PHP image:
COPY --from=composer /usr/bin/composer /usr/bin/composer

Run composer:

docker container exec php.app composer udpate