|
2 | 2 | Docker compose environment for Symfony (also works for Laravel or plain PHP) projects
|
3 | 3 |
|
4 | 4 | # Summary of what is included
|
5 |
| -* PHP 8.1.2 with XDEBUG 3.1.3 |
| 5 | +* PHP 8.2 with XDEBUG 3 |
6 | 6 | * Apache2
|
7 | 7 | * MySQL 8.0
|
8 | 8 | * PhpMyAdmin - manage MySQL
|
9 |
| -* Mailhog - local mailing server to test emails |
10 |
| -* Installs `composer` and `symfony` commands |
| 9 | +* Mailhog - local mailing server |
| 10 | +* Installs `composer` command |
11 | 11 | * Virtualhost configuration dedicated for Symfony projects
|
12 |
| -* Latest stable NPM and Yarn |
13 |
| -* Latest stable Node.js |
14 | 12 |
|
15 | 13 | # How to install this in my project?
|
16 | 14 |
|
17 |
| -* Download `.docker` folder and `docker-compose.yml` file and add them to your project (Don't download `.github` folder) |
18 |
| -* Run `docker-compose up` command from your terminal. [(Install docker compose)](https://docs.docker.com/compose/install/) |
| 15 | +* Download `.docker` folder and `docker-compose.yml` file and add them to your project (Skip `.github` and `public` folders) |
| 16 | +* Run `docker compose up` command from your terminal. [(Install docker compose)](https://docs.docker.com/compose/install/) |
19 | 17 |
|
20 | 18 | # How to access everything?
|
21 | 19 |
|
22 | 20 | By default you can access services via:
|
23 |
| -* Access your project website via - http://192.168.2.2/ |
24 |
| -* MySQL can be accessed via 192.168.2.3:3306 |
25 |
| -* PhpMyAdmin can be accessed via http://192.168.2.4/ |
26 |
| -* Mailhog can be accessed via http://192.168.2.5:8025/ |
| 21 | +* Access your project website via - http://localhost/ |
| 22 | +* MySQL can be accessed via localhost:3306 |
| 23 | +* PhpMyAdmin can be accessed via http://localhost:81 |
| 24 | +* Mailhog can be accessed via http://localhost:8025/ |
27 | 25 | * Access docker apache-php terminal by writing - `docker exec -it project_web bash`
|
28 | 26 |
|
29 | 27 | # Modifying .env file (If you are using Symfony)
|
30 | 28 |
|
31 | 29 | If you use default IP addresses, append your `.env` file with the following:
|
32 | 30 |
|
33 |
| -* For database connection -`DATABASE_URL=mysql://project:project@192.168.2.3:3306/project` |
34 |
| -* For mailing server - `MAILER_URL=mailhog:1025//randomemail@gmail.com:randompassword` (You don't need to change email or password) |
| 31 | +* For database connection -`DATABASE_URL=mysql://project:project@mysql:3306/project` |
| 32 | +* For mailing server - `MAILER_URL=mailhog:1025//randomemail@gmail.com:randompassword` (You can you any email and password) |
35 | 33 |
|
36 | 34 | # MySQL
|
37 | 35 |
|
38 |
| -* If you haven't modified IP addresses, you can connect to your MySQL via 192.168.2.3:3306 |
39 |
| -* If you don't have any additional software, you can connect to database via phpmyadmin (http://192.168.2.4/) |
40 |
| -* Nickname: `project` |
| 36 | +* You can connect to your MySQL via `localhost:3306` |
| 37 | +* If you don't have any additional software, you can connect to database via phpmyadmin (http://localhost:81) |
| 38 | +* Username: `project` |
41 | 39 | * Password: `project`
|
42 | 40 | * Default table is called `project`
|
43 | 41 |
|
44 | 42 | # Notes and common issues
|
45 | 43 |
|
46 |
| -* You cannot use same configuration for multiple projects. Docker won't allow you to allocate same IP addresses for multiple containers. |
47 |
| -* You would need to modify `docker-compose.yml` IP addresses. For example from `192.168.2.0/24` to `192.168.3.0/24` |
| 44 | +* I use this configuration on `Windows 11` with `WSL 2` |
| 45 | +* You cannot use same `container_name` for multiple projects. Make sure to change them, or you can just delete that optional argument from `docker-compose.yml` file |
| 46 | +* You can't run multiple projects that allocate same ports on your localhost. |
48 | 47 | * If you can't compose a new project, you might need to delete your old docker networks. Type `docker network ls` and then remove your old project network by writing `docker network rm NETWORK_ID` (for example `docker network rm 528d8c753c17`)
|
49 | 48 | * `cannot start service XXX: network YYY not found`. Open up container list with `docker container ls -a` and remove old containers with `docker container rm ID`.
|
50 | 49 |
|
|
0 commit comments