Symfony Quickstart Environment
A Symfony development environment with PHP8, NGINX and MariaDB.
This should get you up and running on a new Symfony project in a matter of minutes, provided you have the required applications pre-installed.
System Requirements
- docker
- docker-compose
- composer (see creating a Docker powered composer alias here)
Setup
- Clone this repository or create a new repository from this template and follow the instructions below
# change danostech/symfony-quickstart.git to your repository if using this as a template
$ git clone [email protected]:danostech/symfony-quickstart.git your_app_name
- Create your symfony project. This MUST be called
app
.
$ cd your_app_name
$ composer create-project symfony/skeleton app
- Update ports, container names, and environment variables 1
# update container names in docker-compose.yml and the console helper file
# avoid using spaces or special characters here
# linux
$ sed -i s/quickstart/your_app_name/g {.env,docker-compose.yml,console}
# OSX
$ sed -i '' s/quickstart/your_app_name/g {.env,docker-compose.yml,console}
# Windows (if you know what the proper command is, please comment or open a pull request)
$ ¯\_(ツ)_/¯
# .env (extra optional)
# make changes to your MYSQL_USER, MYSQL_PASSWORD, and MYSQL_DATABASE environment variables
- Run docker-compose
$ docker-compose up -d
- Check Symfony installation via the console 2
$ ./console about
-------------------- ---------------------------------
Symfony
-------------------- ---------------------------------
Version 5.3.10
Long-Term Support No
End of maintenance 01/2022 (in +83 days)
End of life 01/2022 (in +83 days)
-------------------- ---------------------------------
Kernel
-------------------- ---------------------------------
Type App\Kernel
Environment dev
Debug true
Charset UTF-8
Cache directory ./var/cache/dev (674 KiB)
Build directory ./var/cache/dev (674 KiB)
Log directory ./var/log (0 B)
-------------------- ---------------------------------
PHP
-------------------- ---------------------------------
Version 8.0.12
Architecture 64 bits
Intl locale n/a
Timezone UTC (2021-11-09T06:36:12+00:00)
OPcache false
APCu false
Xdebug true
-------------------- ---------------------------------
- Visit http://localhost:8080 in your browser to view your new symfony app.
Additional Notes
Environment Variables
Any environment variables created in .env
will be available in the php-fpm container.
Speed up the initial build (for slower machines)
This will pull in an image identical what would be built using the current Dockerfile. 3
Edit Dockerfile
and change:
# The latest PHP fpm-buster image
FROM php:fpm-buster
# Path to Symfony's console
ENV PATH="${PATH}:/app/bin"
# Install PDO and PDO_MySQL extensions
RUN docker-php-ext-install pdo pdo_mysql
# Install & Enable xdebug
RUN pecl install xdebug && docker-php-ext-enable xdebug
to:
# The latest Symfony Quickstart image
FROM danostech/php:symfony-quickstart
Footnotes
-
Modifying these values is completely optional. However, creating multiple networks from this template on the same host machine will require you to change ports and container names.
↩ -
If for some reason
./console
is not executable, runchmod +x ./console
first.↩ -
I did not include this in the original
docker-compose.yml
file because I HATE when I'm looking for some guidance on how to setup a Docker network and the advice is to "use this image I built!". That being said if you're on a slower computer, use the image I built to speed things up. If not, you'll be waiting a while for the PHP extensions to be compiled.↩