Skip to content

Commit 12e2bda

Browse files
committed
docs: add reference to command line documentation in README
1 parent e6575af commit 12e2bda

File tree

2 files changed

+374
-0
lines changed

2 files changed

+374
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ A complete and modern Docker development environment for PHP applications with N
2323
- Docker Compose (2.0+)
2424
- Make (optional, but recommended)
2525

26+
### Command Line Reference
27+
28+
For users who don't have access to the `make` utility, a complete reference of all available commands with their manual alternatives is provided in the [Command Line Reference](doc/commands.md) document.
29+
2630
## 🛠️ Installation
2731

2832
### Clone the repository

doc/commands.md

Lines changed: 370 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,370 @@
1+
# Docker Nginx PHP MySQL - Command Line Reference
2+
3+
This document provides a comprehensive reference of all available commands in the Docker Nginx PHP MySQL environment. These commands can be executed using the `make` utility or directly with Docker and Docker Compose commands.
4+
5+
## Environment Management Commands
6+
7+
These commands help you manage your development and production environments.
8+
9+
### `init`
10+
11+
Initializes the project by setting up the environment and installing dependencies.
12+
13+
```bash
14+
# Using make
15+
make init
16+
17+
# Manual alternative
18+
cp .env.dev .env
19+
cp web/app/composer.json.dist web/app/composer.json
20+
docker compose up -d
21+
docker compose exec php composer install -d /var/www/html/app
22+
```
23+
24+
### `dev`
25+
26+
Configures the environment for development.
27+
28+
```bash
29+
# Using make
30+
make dev
31+
32+
# Manual alternative
33+
cp .env.dev .env
34+
docker compose restart
35+
```
36+
37+
### `prod`
38+
39+
Configures the environment for production.
40+
41+
```bash
42+
# Using make
43+
make prod
44+
45+
# Manual alternative
46+
cp .env.prod .env
47+
docker compose restart
48+
```
49+
50+
### `start`
51+
52+
Starts all services defined in the Docker Compose file.
53+
54+
```bash
55+
# Using make
56+
make start
57+
58+
# Manual alternative
59+
docker compose up -d
60+
```
61+
62+
### `stop`
63+
64+
Stops all services and removes containers.
65+
66+
```bash
67+
# Using make
68+
make stop
69+
70+
# Manual alternative
71+
docker compose down
72+
```
73+
74+
### `restart`
75+
76+
Restarts all services.
77+
78+
```bash
79+
# Using make
80+
make restart
81+
82+
# Manual alternative
83+
docker compose down
84+
docker compose up -d
85+
```
86+
87+
### `status`
88+
89+
Displays the status of all containers.
90+
91+
```bash
92+
# Using make
93+
make status
94+
95+
# Manual alternative
96+
docker compose ps
97+
```
98+
99+
### `logs`
100+
101+
Displays and follows log output from all containers.
102+
103+
```bash
104+
# Using make
105+
make logs
106+
107+
# Manual alternative
108+
docker compose logs -f
109+
```
110+
111+
## PHP Development Commands
112+
113+
These commands help with PHP dependency management and code quality.
114+
115+
### `composer-install`
116+
117+
Installs PHP dependencies using Composer.
118+
119+
```bash
120+
# Using make
121+
make composer-install
122+
123+
# Manual alternative
124+
docker compose exec php composer install -d /var/www/html/app
125+
```
126+
127+
### `composer-update`
128+
129+
Updates PHP dependencies to their latest versions.
130+
131+
```bash
132+
# Using make
133+
make composer-update
134+
135+
# Manual alternative
136+
docker compose exec php composer update -d /var/www/html/app
137+
```
138+
139+
### `composer-autoload`
140+
141+
Updates the Composer autoloader.
142+
143+
```bash
144+
# Using make
145+
make composer-autoload
146+
147+
# Manual alternative
148+
docker compose exec php composer dump-autoload -d /var/www/html/app
149+
```
150+
151+
### `test`
152+
153+
Runs PHPUnit tests.
154+
155+
```bash
156+
# Using make
157+
make test
158+
159+
# Manual alternative
160+
docker compose exec php ./app/vendor/bin/phpunit --colors=always --configuration ./app/
161+
```
162+
163+
### `code-sniff`
164+
165+
Checks the code against PSR2 coding standards.
166+
167+
```bash
168+
# Using make
169+
make code-sniff
170+
171+
# Manual alternative
172+
docker compose exec php ./app/vendor/bin/phpcs -v --standard=PSR2 app/src
173+
```
174+
175+
### `phpmd`
176+
177+
Analyzes code with PHP Mess Detector.
178+
179+
```bash
180+
# Using make
181+
make phpmd
182+
183+
# Manual alternative
184+
docker compose exec php ./app/vendor/bin/phpmd ./app/src text cleancode,codesize,controversial,design,naming,unusedcode
185+
```
186+
187+
### `apidoc`
188+
189+
Generates API documentation.
190+
191+
```bash
192+
# Using make
193+
make apidoc
194+
195+
# Manual alternative
196+
docker run --rm -v $(pwd):/data phpdoc/phpdoc -i=vendor/ -d /data/web/app/src -t /data/web/app/doc
197+
```
198+
199+
## Database Commands
200+
201+
These commands help manage the MySQL database.
202+
203+
### `db-dump`
204+
205+
Creates a backup of all databases.
206+
207+
```bash
208+
# Using make
209+
make db-dump
210+
211+
# Manual alternative
212+
mkdir -p data/db/dumps
213+
docker exec $(docker compose ps -q mysqldb) mysqldump --all-databases -u"root" -p"root" > data/db/dumps/db.sql
214+
```
215+
216+
### `db-restore`
217+
218+
Restores a backup of all databases.
219+
220+
```bash
221+
# Using make
222+
make db-restore
223+
224+
# Manual alternative
225+
docker exec -i $(docker compose ps -q mysqldb) mysql -u"root" -p"root" < data/db/dumps/db.sql
226+
```
227+
228+
### `db-connect`
229+
230+
Opens a MySQL shell.
231+
232+
```bash
233+
# Using make
234+
make db-connect
235+
236+
# Manual alternative
237+
docker exec -it $(docker compose ps -q mysqldb) mysql -u"root" -p"root"
238+
```
239+
240+
### `db-volume-create`
241+
242+
Creates a named volume for MySQL data.
243+
244+
```bash
245+
# Using make
246+
make db-volume-create
247+
248+
# Manual alternative
249+
docker volume create docker_nginx_php_mysql_mysql_data
250+
```
251+
252+
### `db-volume-remove`
253+
254+
Removes the MySQL data volume.
255+
256+
```bash
257+
# Using make
258+
make db-volume-remove
259+
260+
# Manual alternative
261+
docker volume rm docker_nginx_php_mysql_mysql_data
262+
```
263+
264+
## Framework Installation Commands
265+
266+
These commands install popular PHP frameworks.
267+
268+
### `install-symfony`
269+
270+
Installs the Symfony framework.
271+
272+
```bash
273+
# Using make
274+
make install-symfony
275+
276+
# Manual alternative
277+
docker compose exec php composer create-project symfony/skeleton symfony-app
278+
```
279+
280+
### `install-laravel`
281+
282+
Installs the Laravel framework.
283+
284+
```bash
285+
# Using make
286+
make install-laravel
287+
288+
# Manual alternative
289+
docker compose exec php composer create-project laravel/laravel laravel-app
290+
```
291+
292+
## Utility Commands
293+
294+
These commands provide various utilities.
295+
296+
### `clean`
297+
298+
Cleans up directories for a reset.
299+
300+
```bash
301+
# Using make
302+
make clean
303+
304+
# Manual alternative
305+
rm -rf web/app/vendor
306+
rm -rf web/app/composer.lock
307+
rm -rf web/app/doc
308+
rm -rf web/app/report
309+
rm -rf etc/ssl/*
310+
rm -rf .phpdoc
311+
```
312+
313+
### `clean-all`
314+
315+
Cleans all data including Docker volumes.
316+
317+
```bash
318+
# Using make
319+
make clean-all
320+
321+
# Manual alternative
322+
rm -rf web/app/vendor
323+
rm -rf web/app/composer.lock
324+
rm -rf web/app/doc
325+
rm -rf web/app/report
326+
rm -rf etc/ssl/*
327+
rm -rf .phpdoc
328+
docker volume rm docker_nginx_php_mysql_mysql_data
329+
```
330+
331+
### `gen-certs`
332+
333+
Generates SSL certificates.
334+
335+
```bash
336+
# Using make
337+
make gen-certs
338+
339+
# Manual alternative
340+
docker run --rm -v $(pwd)/etc/ssl:/certificates -e "SERVER=localhost" \
341+
alpine:latest /bin/sh -c "apk add --no-cache openssl && \
342+
openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
343+
-keyout /certificates/server.key -out /certificates/server.crt \
344+
-subj '/CN=localhost'"
345+
```
346+
347+
### `enable-ssl`
348+
349+
Enables SSL in the Nginx configuration.
350+
351+
```bash
352+
# Using make
353+
make enable-ssl
354+
355+
# Manual alternative
356+
cp etc/nginx/default.template.conf etc/nginx/default.conf
357+
# Then manually uncomment the SSL server block in the configuration file
358+
docker compose restart
359+
```
360+
361+
## Notes for Windows Users
362+
363+
If you're using Windows and don't have access to the `make` command, you can:
364+
365+
1. Install Make for Windows through [GnuWin32](http://gnuwin32.sourceforge.net/packages/make.htm)
366+
2. Use WSL (Windows Subsystem for Linux)
367+
3. Use the manual alternative commands listed above
368+
4. Use Git Bash which provides a Unix-like terminal
369+
370+
For specific Windows issues or if you encounter any problems, please refer to the project's GitHub issue tracker.

0 commit comments

Comments
 (0)