lch / docker-symfony
Ready-To-Start LAMP stack with Symfony and PHPMyAdmin
Installs: 12
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 1
Language:Makefile
Type:project
This package is auto-updated.
Last update: 2020-09-21 15:50:45 UTC
README
This boilerplate is a ready-to-start customizable LAMP stack with Symfony and PHPMyAdmin integration. Warning : for Linux/Mac users only.
Installation
Use Composer to initiate project.
composer create-project lch/docker-symfony target-dir 0.1.2
Configuration
Custom parameters
.env file
First of all, specify parameters needed for the project
Directories
- RELATIVE_APP_PATH: This is the relative path from project initial path. Default to
./
. Note: a volume will be created on this path in order to persist Symfony app files. - LOGS_DIR: The logs directory.
Host
- HOST_USER: Your current username. Needed to ensure creation (directories...) with your current user to preserve mapping between container and host
- HOST_UID: Your current user host ID (uid). This is mandatory to map the UID between PHP container and host, in order to let you edit files both in container an through host volume access.
- HOST_GID: Your current main group host ID (gid). (Not used so far)
Project
- PROJECT_NAME: The project name.
Database
- MYSQL_HOST: The database host. Has to be equal to database container name in
docker-compose.yml
file (defaultmysql
). - MYSQL_DATABASE: The database name you want
- MYSQL_USER: user that will be created on image creation
- MYSQL_PASSWORD: the database password you want for above user
- MYSQL_HOST_PORT: the port you want to be able to reach the MySQL server (from the host) on.
- MYSQL_PORT: the MySQL instance port. Careful, this is the MySQL port in container. Default to
3306
- MYSQL_HOST_VOLUME_PATH: default
./data/mysql/5.7
. This is the volume which will store database.
Ports
You can have multiple projects using this boilerplate, but without changing ports, only one project can be up at a time.
- APPLICATION_WEB_PORT: default to
8800
. - PHP_MY_ADMIN_PORT: default to
8801
.
Usage
There are 2 ways to use this : initialisation and day-to-day usage.
Initialisation
You have to run make install-symfony
. This script will
- execute the
composer create-project
command for installing Symfony - Copy the
.env
content from Symfony app to existing.env
. - Copy the
.gitignore
content from Symfony app to existing.gitignore
.
Note : once .env
updated, after Symfony install, you have to edit the elements added to make them use predefined variables (for example MySQL connection URL).
Day-to-day usage
Then, on day-to-day usage, just run
make up
to make system livemake down
to shutdown this project with containers removal.
Note : All volumes set will ensure to persist both app files and database.
Makefile
commands available
assets-install
Execute Symfony assets:install --symlink
command.
bash-php
Gives a shell in php container with www-data user.
bash-php-root
Gives a shell in php container with root user.
build
Build the containers. To be used to force containers recreation.
cache-clear
Execute Symfony cache clear command.
composer-install
Execute composer install
.
dsu-dump
This runs a doctrine:schema:update --dump-sql
.
dsu-force
This runs a doctrine:schema:update --force
.
down
Down the containers.
encore-dev
Make an Encore assets generation (dev mode).
encore-prod
Make an Encore assets generation (prod mode).
encore-watch
Make an Encore assets generation (watch mode).
fixtures-load
This runs a doctrine:fixtures:load
.
install-symfony
Install Symfony as described above. Will also install the Maker and Migrations bundle.
install-app
Execute all steps to install your app on top of Symfony installation. This commands executes :
build
command.composer-install
command.composer-install
command.migrate
command.- Configure
Yarn
cache and global folder. - Install NPM packages.
- Run a production assets generation.
make-migration
This runs a make:migration
.
migrate
This runs a doctrine:migrations:migrate
.
up
Makes system live. Also substitute www-data
UID with given UID to avoid write permissions problems.
PhpMyAdmin
Accessible on localhost:8801
by default. Use MYSQL_USER
and MYSQL_PASSWORD
to connect.