docker-symfony-vue
Environment composition:
- Docker Compose
- Nginx, PHP-FPM 7.2 and Xdebug (works on macOS)
- MySQL
- Symfony 4.2
- Node, Webpack and Vue.js
Project structure
.
├── app // Symfony app directory
│ ├── assets // Folder generated by symfony/webpack-encore-bundle
│ │ └── vue
│ ├── bin
│ ├── config // Symfony app config
│ │ ├── packages
│ │ │ ├── dev
│ │ │ ├── prod
│ │ │ └── test
│ │ └── routes
│ │ └── dev
│ ├── public // This is where the index.php lies
│ │ └── build // And that is responsible for building your js to index.js
│ ├── src // Your Symfony app core stuff
│ │ ├── Controller
│ │ ├── Entity
│ │ ├── Migrations
│ │ └── Repository
│ ├── templates // Twig templates
│ ├── tests
│ ├── translations
│ └── var
│ ├── cache
│ └── log
├── docker
│ ├── config // Directory with nginx/php configurations.
│ │ ├── nginx
│ │ │ ├── hosts
│ │ │ └── xdebug
│ │ └── php
│ └── php // Here lies php Dockerfile
└── logs // Docker containers' logs
Installation
-
Create a
./.env
from the./.env.dist
file. Adapt it according to your symfony applicationcp .env.dist .env
-
Set up database connection
Take care about DATABASE_URL parameter in
./app/.env
-
Build and run Docker containers
Make sure that 80 port is not in use or change Nginx port in
./docker/config/nginx/hosts/default.conf
and also in docker-compose filesdocker-compose up --build -d
Note:
Docker containers can be launched with docker-sync
I highly recommend macOS users to use that way because of these performance tests
My page loading time decreased from 8 seconds to 250 ms
To use it you need to install docker-sync on your machine (link above)
After you build Docker container withdocker-compose build
Usemake start_dev
andmake stop_dev
to control your containersIf you don't need docker-sync delete
docker-compose-dev.yml
docker-sync.yml
andMakefile
from the project root -
Install vendors
cd ./app composer install npm install
Usage
- Run your containers
docker-compose up -d
ormake start_dev
- Run webpack watch command
npm run watch
You can also find
dev
adnbuild
commands in package.json file - Go to http://localhost:80/
Welcome to your application!
PhpStorm config
-
Use Docker container's PHP
Go to
Preferences > Languages & Frameworks > PHP
Click on...
near the CLI Interpreter
Add new instance from Docker
-
Use path mappings
Go to
Preferences > Languages & Frameworks > PHP > Servers
Create mappings from your./app
tovar/www/app
-
Xdebug config
-
Database configuration
Use 3307 for mysql connection port or change it in docker-compose files