-
Notifications
You must be signed in to change notification settings - Fork 1
/
xdebug
executable file
·63 lines (48 loc) · 1.08 KB
/
xdebug
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
#!/bin/sh
if [ $# -eq 0 ] || [ "--help" = "$1" ] || [ "-h" = "$1" ]
then
default=$(printf "\033[0m")
title=$(printf "\033[33m")
info=$(printf "\033[32m")
cat <<USAGE
${title}Usage:${default}
xdebug [-h|--help] [<command>]
${title}Help:${default}
The ${info}xdebug${default} command allows to run a PHP command with Xdebug remote debug enabled.
Run a local executable PHP script:
${info}xdebug bin/console symfony:command${default}
Run the PHP command:
${info}xdebug php script.php${default}
USAGE
if [ $# -eq 0 ]
then
exit 3
fi
exit 0
fi
run_with_xdebug() {
if ! command -v php > /dev/null
then
echo "Command php not found"
exit 4
fi
XDEBUG_CONFIG=1 php -dzend_extension=xdebug "$@"
}
if [ -f "$1" ]
then
run_with_xdebug "$@"
exit 0
fi
command="$1"
shift
if [ "php" != "$command" ]
then
if ! command -v "$command" > /dev/null 2>&1
then
echo "Not a PHP file or a command: $command"
exit 4
fi
run_with_xdebug "$(command -v "$command")" "$@"
else
run_with_xdebug "$@"
fi