Richard Mendes
October 05, 2025 •
5 Mins
First we need Dockerfile, So lets create one, copy this code, create a file in your folder called Dockerfile and paste this code
FROM php:8.2.28-apache
RUN apt-get update && apt-get install -y \
git unzip libicu-dev libzip-dev zip \
&& docker-php-ext-install intl opcache pdo pdo_mysql zip \
&& a2enmod rewrite
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
COPY ./backend/ /var/www/html/
WORKDIR /var/www/html/
# Adjust permissions
RUN chown -R www-data:www-data /var/www/html \
&& chmod -R 755 /var/www/html
For explanation of the files please refer my video, which is right at the bottom.
Next create a docker-compose.yml file and paste the following code.
version: "3.8"
services:
php-apache:
build: .
container_name: my-symfony-container
ports:
- "8080:80"
volumes:
- ./backend:/var/www/html
Note: You need to create a backend folder, so all php file will be ran in backend folder.
Install Symfony 7 and API Platform now
Install Symfony Skeleton using the below command, this will be installed in backend directory
composer create-project symfony/skeleton .
Next Install API Platform
Now go to your public directory and create an .htaccess file, and put this code in your file
<IfModule mod_rewrite.c>
RewriteEngine On
# If a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward it to index.php
RewriteRule ^ index.php [QSA,L]
</IfModule>
Now to run Symfony 7 Application
http://localhost:8080/public
And to run API Platform
http://localhost:8080/public/api
For detailed explanation, refer this video
https://youtu.be/98ZSfji9XKs