Skip to content

Commit 195c7fb

Browse files
endelwarw00fz
authored andcommitted
Update script to support new homebrew php packages (#16)
* Update script to support new homebrew php packages * Update documentation
1 parent 8a9bcac commit 195c7fb

File tree

2 files changed

+46
-14
lines changed

2 files changed

+46
-14
lines changed

README.md

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ You can follow the _OS X Apache Setup_ guide, divided in two parts, to get the p
2020
curl -L https://raw.githubusercontent.com/w00fz/xdebug-osx/master/xdebug-toggle > /usr/local/bin/xdebug-toggle
2121
```
2222

23-
## Installation with homebrew
24-
25-
```
26-
brew install xdebug-osx
27-
```
28-
2923
## Installation with clone
3024

3125
```
@@ -50,6 +44,35 @@ ln -s `pwd`/xdebug-toggle /usr/local/bin/xdebug-toggle
5044
chmod +x /usr/local/bin/xdebug-toggle
5145
```
5246

47+
## Xdebug installation and configuration
48+
49+
Homebrew does not provide a keg for Xdebug anymore, so you must install Xdebug extension via pecl
50+
51+
```bash
52+
pecl channel-update pecl.php.net
53+
pecl install xdebug
54+
```
55+
56+
`xdebug-toggle` needs a file called `ext-xdebug.ini` in brew's php conf.d directory to work, which must contain, at least, the following:
57+
58+
```ini
59+
zend_extension="xdebug.so"
60+
```
61+
62+
Make sure that `php.ini` doesn't contain this line too.
63+
64+
It's recommended to keep al xdebug config in this file, as an example:
65+
66+
```ini
67+
[xdebug]
68+
zend_extension="xdebug.so"
69+
70+
xdebug.var_display_max_depth=24
71+
xdebug.remote_port=9000
72+
xdebug.remote_enable=1
73+
xdebug.remote_connect_back=1
74+
```
75+
5376
## Usage
5477
```
5578
xdebug-toggle # outputs the current status

xdebug-toggle

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,19 @@
88
app="$(basename "$0")"
99
command="$1"
1010
options="$2"
11-
12-
php_version_dot=$(php -r "\$v=explode('.', phpversion() ); echo implode('.', array_splice(\$v, 0, -1));")
11+
php_version_dot=$(php -r "\$v=explode('.', PHP_VERSION ); echo implode('.', array_splice(\$v, 0, -1));")
1312
php_version="${php_version_dot//./}"
1413

1514
xdebug_conf_path="$(brew --prefix)/etc/php/$php_version_dot/conf.d"
1615
xdebug_conf_file="ext-xdebug.ini"
17-
xdebug_conf=$xdebug_conf_path/$xdebug_conf_file
18-
function keg_exists() { brew list php"${php_version}"-xdebug 2> /dev/null > /dev/null; }
16+
xdebug_conf=${xdebug_conf_path}/${xdebug_conf_file}
17+
extension_dir=$(php -r "echo PEAR_EXTENSION_DIR;")
1918

20-
if keg_exists; then
19+
if [ ! -f "extension_dir"/xdebug.so ]; then
2120
if [ ! -f "$xdebug_conf" ] && [ ! -f "$xdebug_conf.disabled" ]; then
2221
echo ""
2322
echo "The ini file for Xdebug was not found at '$xdebug_conf_path'"
24-
echo "Did you install Xdebug via Homebrew?"
23+
echo "Did you install Xdebug via PECL?"
2524
echo "For more informations: http://github.com/w00fz/xdebug-osx/blob/master/README.md"
2625
echo ""
2726

@@ -51,7 +50,17 @@ if keg_exists; then
5150
STATUS="disabled"
5251
fi
5352

54-
if [ -f ~/Library/LaunchAgents/homebrew.mxcl.php"${php_version}".plist ]; then
53+
current_stable_php_path="/usr/local/opt/php/bin/php"
54+
if [ -f $(eval echo ${current_stable_php_path}) ]; then
55+
current_stable_php_version=$(${current_stable_php_path} -r "\$v=explode('.', PHP_VERSION ); echo implode('.', array_splice(\$v, 0, -1));")
56+
fi
57+
58+
php_plist_file="~/Library/LaunchAgents/homebrew.mxcl.php@$php_version_dot.plist"
59+
if [ "${php_version_dot}" == "${current_stable_php_version}" ]; then
60+
php_plist_file="~/Library/LaunchAgents/homebrew.mxcl.php.plist"
61+
fi
62+
63+
if [ -f $(eval echo ${php_plist_file}) ]; then
5564
IS_PHP_FPM=true
5665
SERVER_NAME="php-fpm"
5766
fi
@@ -84,7 +93,7 @@ if keg_exists; then
8493
fi
8594
else
8695
echo ""
87-
echo "Xdebug for PHP $php_version_dot was never installed or not installed via Brew."
96+
echo "Xdebug for PHP $php_version_dot was never installed or not installed via PECL."
8897
echo "For more informations: http://github.com/w00fz/xdebug-osx/blob/master/README.md"
8998
echo ""
9099
exit 1

0 commit comments

Comments
 (0)