This is a simple Symfony 8.0 demo project using PHP 8.5.
This demo is using AssetMapper. To see a version with Encore, switch to the unmaintained webpack-encore branch.
Downloading the project :
user@host ~$ cd [PATH_WHERE_TO_PUT_THE_PROJECT] # E.g. ~/projects/
user@host projects$ git clone https://github.com/cyrilverloop/symfony-demo.git
user@host projects$ cd symfony-demoThis demo uses Docker images based on :
mariadbfor the database;httpd:alpinefor the web server;php:8.5.0-fpm-alpinefor php files;alpine/opensslto generate a TLS certificate.
The app (php) container depends on the mariadb and httpd containers.
After each docker compose run --rm php ... command,
Docker will not remove the dependencies (mariadb, httpd and network).
You can remove them with :
user@host symfony-demo$ docker compose downIt is recommended to use cache directories for the downloaded dependencies (Composer and Phive). If you do not already have cache directories, create them with :
user@host symfony-demo$ mkdir -p ./.cache/composer/ ./.cache/phive/Default paths are configured in compose.override.yaml.dist
and you can customise them in compose.override.yaml.
Generate a TLS self-signed certificate with the following script :
user@host symfony-demo$ ./tls/create-self-signed-certificate.shCopy the example files :
user@host symfony-demo$ cp compose.override.yaml.dist compose.override.yaml
user@host symfony-demo$ cp ./.env.dist ./.env
user@host symfony-demo$ cp httpd/.ashrc.dist httpd/.ashrc
user@host symfony-demo$ cp php/.ashrc.dist php/.ashrcFill in the variables in ./.env.
These files are in the .gitignore file and can be customised.
Build the images :
user@host symfony-demo$ docker compose buildDefine the database configuration for Symfony (see ./app/.env or ./app/.env.local.dist)
and install the PHP dependencies :
user@host symfony-demo$ docker compose run --rm php composer install -o [--no-dev]The "--no-dev" option is for the production environment.
For the development and the test environments only :
user@host symfony-demo$ docker compose run --rm php phive install --trust-gpg-keys 4AA394086372C20A,12CE0F1D262429A5,31C7E470E2138192,8AC0BAA79732DD42,C5095986493B4AA0user@host symfony-demo$ docker compose run --rm php ./bin/console doctrine:database:create [-e test]
user@host symfony-demo$ docker compose run --rm php ./bin/console doctrine:migrations:migrate [--no-interaction] [-e test]The "-e test" option is to for the test environment which uses Sqlite.
user@host symfony-demo$ docker compose run --rm php bin/console asset-map:compileOnce the installation is complete, you can start the containers with :
user@host symfony-demo$ docker compose up -dThe demo will be available in your browser through : https://localhost:8000/
To stop the containers :
user@host symfony-demo$ docker compose downFirst, you need to configure the app and create the database for the test environment. Then, run the tests :
user@host symfony-demo$ docker compose run --rm php ./tools/phpunit -c ./ci/phpunit.xmlThe generated outputs will be in ./app/ci/phpunit/.
And, run the mutation tests :
user@host symfony-demo$ docker compose run --rm php ./tools/infection -c./ci/infection.jsonThe generated outputs will be in ./app/ci/infection/.
To generate the PHPDoc, use this command after installing phive dependencies :
user@host symfony-demo$ docker compose run --rm php ./tools/phpDocumentor --config ./ci/phpdoc.xmlThe generated HTML documentation will be in ./app/ci/phpdoc/.