|
| 1 | +>  |
| 2 | +
|
1 | 3 | # Docker Compose for local development |
2 | 4 |
|
3 | 5 | > - https ready! |
4 | 6 | > - multiple domain / project support |
5 | 7 | > - PHP Xdebug |
| 8 | +> - php7wrapper |
6 | 9 | > |
7 | 10 | > reference from https://laradock.io |
8 | 11 |
|
|
14 | 17 | - [Change PHP Configuration](#change-php-configuration) |
15 | 18 | - [Information](#info) |
16 | 19 | - ... |
17 | | - - [docker image size preview](#docker-image-size) |
18 | 20 | - [Xdebug & VSCode](#xdebug--vscode) |
| 21 | +- [PHP Wrapper](#php-wrapper) |
19 | 22 |
|
20 | 23 | # Setup |
21 | 24 | - #### download & install docker for MAX(os x) |
|
26 | 29 | >```bash |
27 | 30 | >$ git clone https://github.com/cscolabear/docker-dev.git Projects |
28 | 31 | > |
29 | | - > # [optional] change branch, if you need mysql |
| 32 | + > # [optional] create your local branch e.g. local-dev, and merge branch, if you need mysql or memcached |
30 | 33 | > $ git checkout service/add-mysql |
31 | 34 | > ``` |
| 35 | +
|
32 | 36 | - #### make your folder look like this... (👉 replace `~/Projects` what you want.) |
33 | 37 | > e.g. |
34 | 38 | > |
|
44 | 48 | > ```bash |
45 | 49 | > $ cd ~/Projects |
46 | 50 | > $ chmod -R 755 Logs |
47 | | - > $ dokcer-compose up -d |
| 51 | + > $ dokcer-compose --compatibility up -d |
48 | 52 | > ``` |
| 53 | + > (Compatibility mode: https://docs.docker.com/compose/compose-file/compose-versioning/#compatibility-mode) |
| 54 | + > |
49 | 55 | > |
50 | 56 | > ⏳ Please wait |
| 57 | + > |
51 | 58 |
|
52 | 59 | - #### SSH into a container |
53 | 60 | > ```bash |
54 | | - > $ cd ~/Projects/ && clear && docker-compose exec workspace bash |
| 61 | + > $ cd ~/Projects/ && clear && docker-compose exec WORKSPACE bash |
55 | 62 | > ``` |
56 | 63 | > |
57 | 64 | > looked like after connected~ |
58 | 65 | >  |
59 | | - > you can execute composer, node, npm in here |
| 66 | + > you can execute composer, node, npm in this container |
60 | 67 |
|
61 | 68 | - #### enjoy Docker 🐳 |
62 | 69 | > 👉 create index.php & index.html |
|
111 | 118 | > - modify `Dockerfiles/php-fpm/php.ini` |
112 | 119 | > - restart php-fpm Docker Container |
113 | 120 | > ```base |
114 | | - > $ docker-compose restart fpm |
| 121 | + > $ docker-compose restart FPM |
115 | 122 | >``` |
116 | 123 |
|
117 | 124 | ## Info |
|
136 | 143 | > |
137 | 144 | > ~/Projects/Logs/nginx-error.log |
138 | 145 |
|
139 | | -- #### docker image size |
140 | | - >  |
141 | | -
|
142 | | -
|
143 | | -
|
144 | 146 | - #### Xdebug & VSCode |
145 | 147 | > - install the vscode extension <br> |
146 | 148 | > - PHP Debug |
|
175 | 177 | > ``` |
176 | 178 |
|
177 | 179 | - vscode debug 設定檔每個專案都要設定一次<br> |
178 | | - - 路徑對應重點, 編輯器沒反應時(e.g. vscode) 多半是這個路徑沒有設定正確<br> |
179 | | - 也可以 ssh 至 fpm container 查看 `/tmp/xdebug.log`<br> |
| 180 | + - 路徑對應是重點(pathMappings), 編輯器沒反應時(e.g. vscode) 多半是這個路徑沒有設定正確<br> |
| 181 | + 也可以 ssh 進入 fpm container 查看 `/tmp/xdebug.log`<br> |
180 | 182 | >``` |
181 | 183 | > "pathMappings": { |
182 | 184 | > "/var/www": "${workspaceRoot}" |
183 | 185 | > // or |
184 | 186 | > "/var/www/[your Project folder]": "${workspaceRoot}" |
185 | 187 | > }, |
186 | | - >``` |
| 188 | + >``` |
| 189 | + > |
| 190 | + > - xdebug.ini |
| 191 | + > ; for MAC os x |
| 192 | + > xdebug.remote_host=host.docker.internal |
| 193 | + > |
| 194 | +
|
| 195 | +# PHP Wrapper |
| 196 | + > branch exposure-php 內的 php7wrapper (https://github.com/cscolabear/docker-dev/blob/exposure-php/php7wrapper) |
| 197 | +
|
| 198 | + 因為本機 MAC os x 和 docker 環境內的 PHP 版本不同 |
| 199 | + 所以利用 `php7wrapper` 曝光 docker 內的 php 讓本機開發與執行使用同樣的 php 版本 |
| 200 | +
|
| 201 | + - 將 `exposure-php` branch merge 至 local-dev branch |
| 202 | +
|
| 203 | + ```bash |
| 204 | + $ ln -s ~/Projects/php7wrapper /usr/local/bin php |
| 205 | + $ chmod +x /usr/local/bin php |
| 206 | + ``` |
| 207 | + (MAC osx 原生 PHP path: /usr/bin/php) |
| 208 | +
|
| 209 | +
|
0 commit comments