Skip to content

Commit ea290cf

Browse files
committed
New bin/spx script to enable or disable output compression to disable/enable SPX #1073
1 parent 45ce137 commit ea290cf

File tree

4 files changed

+55
-6
lines changed

4 files changed

+55
-6
lines changed

compose/bin/spx

+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/php.ini | grep -iGc 'zlib.output_compression = 1');
4+
5+
spx_status() {
6+
if [[ $S == 1 ]]; then
7+
echo "Output compression is enabled, so you cannot currently debug with SPX."
8+
else
9+
echo "Output compression is disabled, so you can currently debug with SPX."
10+
fi
11+
}
12+
13+
spx_toggle() {
14+
if [[ $S == 1 ]]; then
15+
spx_enable
16+
else
17+
spx_disable
18+
fi
19+
}
20+
21+
spx_enable() {
22+
if [[ $S == 1 ]]; then
23+
bin/root sed -i -e 's/^zlib.output_compression = 1/zlib.output_compression = 0/g' /usr/local/etc/php/php.ini
24+
sleep 1
25+
bin/restart phpfpm
26+
echo "Output compression is now disabled, so you can start debugging with SPX."
27+
else
28+
echo "Output compression is already disabled, so you can start debugging with SPX."
29+
fi
30+
}
31+
32+
spx_disable() {
33+
if [[ $S == 0 ]]; then
34+
bin/root sed -i -e 's/^zlib.output_compression = 0/zlib.output_compression = 1/g' /usr/local/etc/php/php.ini
35+
sleep 1
36+
bin/restart phpfpm
37+
echo "Output compression is now enabled, so you can no longer debug with SPX."
38+
else
39+
echo "Output compression is already enabled, so you can no longer debug with SPX."
40+
fi
41+
}
42+
43+
firstArgLetter="$(echo "$1" | head -c 1)"
44+
45+
if [[ $firstArgLetter == "d" ]]; then
46+
spx_disable
47+
elif [[ $firstArgLetter == "e" ]]; then
48+
spx_enable
49+
elif [[ $firstArgLetter == "t" ]]; then
50+
spx_toggle
51+
elif [[ $firstArgLetter == "s" ]]; then
52+
spx_status
53+
else
54+
printf "Please specify either 'disable', 'enable', 'status' or 'toggle' as an argument.\nEx: bin/spx status\n"
55+
fi

images/php/8.1/conf/spx.ini

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
zlib.output_compression = 0
2-
31
extension = /usr/lib/php-spx/modules/spx.so
42
spx.http_enabled = 1
53
spx.http_key = "dev"

images/php/8.2/conf/spx.ini

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
zlib.output_compression = 0
2-
31
extension = /usr/lib/php-spx/modules/spx.so
42
spx.http_enabled = 1
53
spx.http_key = "dev"

images/php/8.3/conf/spx.ini

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
zlib.output_compression = 0
2-
31
extension = /usr/lib/php-spx/modules/spx.so
42
spx.http_enabled = 1
53
spx.http_key = "dev"

0 commit comments

Comments
 (0)