In preparation for this project, I implemented the following steps:
- Docker containers created with PHP, Nginx and MySql
- Symfony application created
- Basic framework created with
composer create-project symfony/skeleton /var/www/html
composer require webapp
executed to install extra packages to get everything you need to build a web application
- Basic framework created with
- Symfony CLI installed (Dockerfile extended)
- Added
wget
to installed dependencies - Added
RUN wget https://get.symfony.com/cli/installer -O - | bash && \ mv /root/.symfony*/bin/symfony /usr/local/bin/symfony
- Removed containers
docker compose down
- Created containers
docker compose build
- Started containers
docker compose up -d
- Added
These steps served as preparation to get the Symfony application running. There are different ways to do this including:
These steps no longer need to be carried out for this application. They serve for understanding.
To save time, you can install Symfony Maker or Symfony CLI to use helpful commands.
For this project I am using the Symfony CLI, so every command starts with symfony console
. If you use Symfony Maker, every command starts with php bin/console
symfony console make:controller BrandNewController
created: src/Controller/BrandNewController.php created: templates/brandnew/index.html.twig
symfony console make:crud Product
created: src/Controller/ProductController.php created: src/Form/ProductType.php created: templates/product/_delete_form.html.twig created: templates/product/_form.html.twig created: templates/product/edit.html.twig created: templates/product/index.html.twig created: templates/product/new.html.twig created: templates/product/show.html.twig
In order to make the local URL accessible in the browser, the "hosts file" must be adapted. On Mac and Linux systems they can be found under "/etc/hosts". Add the following entry:
# Symfony Event Manager Demo 127.0.0.1 sfeventmanagerdemo.local
- Clone the repository
- Build the Docker Container
make build
- Run the Docker Container
make startup
- Create
.env
file fromenv.sample
from the root directory level of the web projectcp src/.env.example src/.env
- Open a terminal and go to the root directory level of the web project and run
docker exec -it php-container bash
- Create value for APP_SECRET in .env file and replace it with the new value
openssl rand -hex 32
- Execute
composer install
- Open a new browser tab and enter the domain
http://sfeventmanagerdemo.local:8080/