-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
293 lines (220 loc) · 7.05 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# Project setup commands
#-------------------------------------------------
# Run PHP's built-in server for the public directory
run:
cd public; sudo php -S 0.0.0.0:8030
# Build and start Docker containers (Linux)
docker_run_linux:
sudo docker-compose build
sudo docker-compose up
# Stop Docker containers (Linux)
docker_stop_linux:
sudo docker-compose down
# Build and start Docker containers (Windows)
docker_run_win:
docker-compose build
docker-compose up
# Stop Docker containers (Windows)
docker_stop_win:
docker-compose down
# Production Docker Management Commands
#-------------------------------------------------
# Start the production Docker environment
prod_up:
docker-compose -f docker-compose.prod.yml up -d
# Stop the production Docker environment
prod_down:
docker-compose -f docker-compose.prod.yml down
# Restart the production Docker environment
prod_restart:
make prod_down
make prod_up
# View logs for the production Docker environment
prod_logs:
docker-compose -f docker-compose.prod.yml logs
# Rebuild and start the production Docker environment
prod_rebuild:
docker-compose -f docker-compose.prod.yml up -d --build
# Stop and remove all containers, networks, and volumes
prod_clean:
docker-compose -f docker-compose.prod.yml down -v
# Execute production migrations (adjust command as necessary for your project setup)
prod_migrate:
docker-compose -f docker-compose.prod.yml exec app php spark migrate
# Execute production seeders (adjust command as necessary for your project setup)
prod_seed:
docker-compose -f docker-compose.prod.yml exec app php spark db:seed
# Clear the Redis cache in the production environment
prod_clear_cache:
docker-compose -f docker-compose.prod.yml exec redis redis-cli FLUSHALL
# Database migrations
#-------------------------------------------------
# Run all new migrations to update the database schema
migrate:
php spark migrate
# Show the current status of migrations
migrations_status:
php spark migrate:status
# Rollback all database migrations, effectively deleting all tables
delete_all_tables:
php spark migrate:rollback
# Placeholder for creating a new migration file
create_migration:
echo php spark make:migration NameOfMigration
# Shortcut to update the database to the latest migration
update_db:
php spark migrate:latest
# Database seeding
#-------------------------------------------------
# Placeholder for creating a new seeder file
create_seed:
echo php spark make:seeder NameOfSeeder
# Run all database seeders
all_seeds:
php spark db:seed
# Docker management
#-------------------------------------------------
# Build Docker images based on the docker-compose.yml
build:
docker-compose build
# Start Docker containers in detached mode
up:
docker-compose up -d
# Stop and remove Docker containers
down:
docker-compose down
# Restart Docker containers
restart:
make down
make up
# Linux-specific Docker management commands
build_linux:
sudo docker-compose build
up_linux:
sudo docker-compose up -d
down_linux:
sudo docker-compose down
restart_linux:
make down_linux
make up_linux
# Redis commands
#-------------------------------------------------
# Clear all data from Redis cache
clear_cache:
redis-cli FLUSHALL
# Redis commands within Docker
#-------------------------------------------------
# Clear the Redis cache within Docker
# This command connects to the Redis container and executes the `FLUSHALL` command via redis-cli,
# which deletes all keys from all databases in Redis, effectively clearing the cache.
# Use with caution, as this cannot be undone and will remove all data stored in Redis.
clear_cache_docker:
docker-compose exec redis redis-cli FLUSHALL
# View logs for the Redis service
# This command retrieves and displays the logs for the Redis container,
# which is useful for debugging and monitoring Redis activity.
redis_logs:
docker-compose logs redis
# Stop the Redis service in Docker
# This stops the Redis container without removing it, allowing you to start it again later
# without having to rebuild or recreate the container.
redis_docker_stop:
docker-compose stop redis
# Start the Redis service in Docker
# If the Redis container was previously stopped using `docker-compose stop redis`,
# this command restarts it without needing to recreate the container.
redis_docker_start:
docker-compose start redis
# Code formatting and linting
#-------------------------------------------------
# Automatically fix PHP code style issues
format:
./vendor/bin/phpcbf --standard=./configs/phpcs.xml app/ || true
# Run format using Composer script
format_from_composer:
composer run format
# Lint PHP files for syntax errors
lint:
./vendor/bin/phplint --configuration ./configs/.phplint.yml
# Run lint using Composer script
lint_from_composer:
composer run lint
# Check PHP code style for issues
check_format:
./vendor/bin/phpcs --standard=./configs/phpcs.xml app/ > warnings
# Run check_format using Composer script
check_format_from_composer:
composer run check_format
# Psalm static analysis
#-------------------------------------------------
# Run Psalm for static analysis
psalm:
vendor/bin/psalm --config=./configs/psalm.xml
# Clear Psalm's cache
psalm_clear_cache:
vendor/bin/psalm --clear-cache --config=./configs/psalm.xml
# Force Psalm to run even if up-to-date
psalm_forced_start:
make -B psalm
# Adminer Commands
#-------------------------------------------------
# Start the Adminer service in Docker
adminer_docker_start:
docker-compose start adminer
# Stop the Adminer service in Docker
adminer_docker_stop:
docker-compose stop adminer
# Restart the Adminer service in Docker
adminer_docker_restart:
docker-compose restart adminer
# Connect to the Adminer container
adminer_shell:
docker-compose exec adminer sh
# MySQL Commands
#-------------------------------------------------
# Start the MySQL service in Docker
mysql_docker_start:
docker-compose start mysql
# Stop the MySQL service in Docker
mysql_docker_stop:
docker-compose stop mysql
# Restart the MySQL service in Docker
mysql_docker_restart:
docker-compose restart mysql
# Connect to the MySQL container
mysql_shell:
docker-compose exec mysql bash
# Nginx Commands
#-------------------------------------------------
# Start the Nginx service in Docker
nginx_docker_start:
docker-compose start nginx
# Stop the Nginx service in Docker
nginx_docker_stop:
docker-compose stop nginx
# Restart the Nginx service in Docker
nginx_docker_restart:
docker-compose restart nginx
# Connect to the Nginx container
nginx_shell:
docker-compose exec nginx sh
# Scripts Commands
#-------------------------------------------------
# Start the project with optional environment argument (e.g., make start_project ENV=production)
start_project:
./scripts/start_project.sh $(ENV)
# Stop the project
stop_project:
./scripts/stop_project.sh
# Restart the project
restart_project:
./scripts/restart_project.sh
# Run migrations
migrate:
./scripts/run_migrations.sh
# Run seeders (use SEEDER=seeder_name to specify a seeder)
seed:
./scripts/run_seed.sh $(SEEDER)
# Clear Redis cache with confirmation
clear_cache:
./scripts/clear_cache.sh