Symfony-Docker gives you everything you need for running/developing application using Symfony 4
Used docker-sync to run your application at full speed on OSX/Windows
- docker https://docs.docker.com/docker-for-mac/
- docker-sync http://docker-sync.io/
-
Clone this repo
$ git clone git@github.com:intelligentbee/symfony_docker.git
-
Build containers
$ make build
-
Create the Symfony project
$ script/install composer create-project symfony/website-skeleton app
-
Update the
DATABASE_URLon theapp/.envfileDATABASE_URL=mysql://root:root@mysql:3306/db_name
-
Start the containers
$ make start
-
See the application in the browser on
http://localhost:8080 -
Enjoy :-)
-
The Symfony application is under
appfolder. -
Useful commands:
maketo see all the commandsmake startto start the containers and the applicationmake stopto stop the containers and the applicationmake dbmigrateto run migrations on the database if you created new migrations on your projectmake composerto run composer install if you added a new packagemake ccto clear the cache of the applicationmake permissionto fix the permission if you have this issue on your applicationmake ngrokStart ngrok server
-
Run commands on the PHP container:
script/exec [your command]for examplescript/exec bin/console cache:warmup
-
Install using composer a new package on your project
script/exec composer require [package name]
- Web application
- Apache port is
8080-http://localhost:8080
- Apache port is
- MySQL
- you can use a SQL tool to access the database using
127.0.0.1for hostrootfor passwordrootfor username4003for port
- on the Symfony project you need to use these settings:
mysqlfor hostrootfor passwordrootfor username3306for portDATABASE_URL=mysql://root:root@mysql:3306/db_namethis is the row fromapp/.envfile
- you can use a SQL tool to access the database using
Have a look at the docker-compose.yml file to see the configuration, here are the docker-compose built images:
mysql: This is the MySQL database containerphp: This is the PHP-FPM container in which the application is mounted onapache: This is the Apache webserver container in which application is mounted too- all these containers are under the network
symfony_ntw
This results in the following running containers:
$ docker-compose ps
Name Command State Ports
------------------------------------------------------------------------------------------------
symfony_apache /bin/sh -c apachectl -DFO ... Up 443/tcp, 0.0.0.0:8080->80/tcp
symfony_mysql docker-entrypoint.sh mysqld Up 0.0.0.0:4003->3306/tcp, 33060/tcp
symfony_php docker-php-entrypoint php-fpm Up 80/tcp, 9000/tcpIf you find any typo/misconfiguration/... please create a PR or open an issue. While creating your Pull Request on GitHub, please write a description which gives the context and explains why you are creating it.
If you need help, please don't hesitate to ask