Skip to content

Commit 3b186b0

Browse files
authored
Merge pull request #1115 from markshust/feature/blackfire-helper-script
New `bin/blackfire` script to enable, disable, or check status of Blackfire extension
2 parents 780133a + e6d11d4 commit 3b186b0

File tree

3 files changed

+59
-2
lines changed

3 files changed

+59
-2
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ It is recommended to keep your root docker config files in one repository, and y
286286

287287
- `bin/analyse`: Run `phpstan analyse` within the container to statically analyse code, passing in directory to analyse. Ex. `bin/analyse app/code`
288288
- `bin/bash`: Drop into the bash prompt of your Docker container. The `phpfpm` container should be mainly used to access the filesystem within Docker.
289+
- `bin/blackfire`: Disable or enable Blackfire. Accepts argument `disable`, `enable`, or `status`. Ex. `bin/blackfire enable`
289290
- `bin/cache-clean`: Access the [cache-clean](https://github.com/mage2tv/magento-cache-clean) CLI. Note the watcher is automatically started at startup in `bin/start`. Ex. `bin/cache-clean config full_page`
290291
- `bin/check-dependencies`: Provides helpful recommendations for dependencies tailored to the chosen Magento version.
291292
- `bin/cli`: Run any CLI command without going into the bash prompt. Ex. `bin/cli ls`
@@ -346,7 +347,7 @@ It is recommended to keep your root docker config files in one repository, and y
346347
- `bin/stop`: Stop all project containers.
347348
- `bin/stopall`: Stop all docker running containers
348349
- `bin/update`: Update your project to the most recent version of `docker-magento`.
349-
- `bin/xdebug`: Disable or enable Xdebug. Accepts params `disable` (default) or `enable`. Ex. `bin/xdebug enable`
350+
- `bin/xdebug`: Disable or enable Xdebug. Accepts argument `disable`, `enable`, or `status`. Ex. `bin/xdebug enable`
350351

351352
## Misc Info
352353

compose/Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ help:
2121
@echo "$(call red,===============================)"
2222
@echo "$(call format,analyse,'Run `phpstan analyse` within the container to statically analyse code, passing in directory to analyse.')"
2323
@echo "$(call format,bash,'Drop into the bash prompt of your Docker container.')"
24+
@echo "$(call format,blackfire,'Disable or enable Blackfire. Accepts argument `disable`, `enable`, or `status`.')"
2425
@echo "$(call format,cache-clean,'Access the cache-clean CLI.')"
2526
@echo "$(call format,check-dependencies,'Provides helpful recommendations for dependencies.')"
2627
@echo "$(call format,cli,'Run any CLI command without going into the bash prompt.')"
@@ -81,7 +82,7 @@ help:
8182
@echo "$(call format,stop,'Stop all project containers.')"
8283
@echo "$(call format,stopall,'Stop all docker running containers.')"
8384
@echo "$(call format,update,'Update your project to the latest version of docker-magento.')"
84-
@echo "$(call format,xdebug,'Disable or enable Xdebug.')"
85+
@echo "$(call format,xdebug,'Disable or enable Xdebug. Accepts argument `disable`, `enable`, or `status`.')"
8586

8687

8788
analyse:

compose/bin/blackfire

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env bash
2+
3+
S=$(bin/clinotty cat /usr/local/etc/php/conf.d/blackfire.ini | grep -iGc '\;extension=blackfire.so');
4+
5+
blackfire_status() {
6+
if [[ $S == 1 ]]; then
7+
echo "Blackfire is disabled."
8+
else
9+
echo "Blackfire is enabled."
10+
fi
11+
}
12+
13+
blackfire_toggle() {
14+
if [[ $S == 1 ]]; then
15+
blackfire_enable
16+
else
17+
blackfire_disable
18+
fi
19+
}
20+
21+
blackfire_enable() {
22+
if [[ $S == 1 ]]; then
23+
bin/root sed -i -e 's/^;extension=blackfire.so/extension=blackfire.so/g' /usr/local/etc/php/conf.d/blackfire.ini
24+
sleep 1
25+
bin/restart phpfpm
26+
echo "Blackfire has been enabled."
27+
else
28+
echo "Blackfire is already enabled."
29+
fi
30+
}
31+
32+
blackfire_disable() {
33+
if [[ $S == 0 ]]; then
34+
bin/root sed -i -e 's/^extension=blackfire.so/;extension=blackfire.so/g' /usr/local/etc/php/conf.d/blackfire.ini
35+
sleep 1
36+
bin/restart phpfpm
37+
echo "Blackfire has been disabled."
38+
else
39+
echo "Blackfire is already disabled."
40+
fi
41+
}
42+
43+
firstArgLetter="$(echo "$1" | head -c 1)"
44+
45+
if [[ $firstArgLetter == "d" ]]; then
46+
blackfire_disable
47+
elif [[ $firstArgLetter == "e" ]]; then
48+
blackfire_enable
49+
elif [[ $firstArgLetter == "t" ]]; then
50+
blackfire_toggle
51+
elif [[ $firstArgLetter == "s" ]]; then
52+
blackfire_status
53+
else
54+
printf "Please specify either 'disable', 'enable', 'status' or 'toggle' as an argument.\nEx: bin/blackfire status\n"
55+
fi

0 commit comments

Comments
 (0)