I had some issues yesterday trying to use some Pear libraries in a web app.
So, I checked my Pear config:
me:ZendServer laran$ pear config-show Configuration (channel pear.php.net): ===================================== Auto-discover new Channels auto_discoverDefault Channel default_channel pear.php.net HTTP Proxy Server Address http_proxy PEAR server [DEPRECATED] master_server pear.php.net Default Channel Mirror preferred_mirror pear.php.net Remote Configuration File remote_config PEAR executables directory bin_dir /opt/local/share/pear/bin PEAR documentation directory doc_dir /opt/local/share/pear/PEAR/docs PHP extension directory ext_dir /Applications/ZendServer/lib/php/20060613 PEAR directory php_dir /opt/local/share/pear/PEAR PEAR Installer cache directory cache_dir /tmp/pear/cache PEAR configuration file cfg_dir /Applications/ZendServer/share/pear/cfg directory PEAR data directory data_dir /opt/local/share/pear/PEAR/data PEAR Installer download download_dir /opt/local/share/pear/temp/download directory PHP CLI/CGI binary php_bin /Applications/ZendServer/bin/php php.ini location php_ini PEAR Installer temp directory temp_dir /opt/local/share/pear/temp PEAR test directory test_dir /opt/local/share/pear/PEAR/tests PEAR www files directory www_dir /Applications/ZendServer/share/pear/htdocs Cache TimeToLive cache_ttl 3600 Preferred Package State preferred_state stable Unix file mask umask 22 Debug Log Level verbose 1 PEAR password (for password maintainers) Signature Handling Program sig_bin /usr/local/bin/gpg Signature Key Directory sig_keydir /Applications/ZendServer/etc/pearkeys Signature Key Id sig_keyid Package Signature Type sig_type gpg PEAR username (for username maintainers) User Configuration File Filename /Users/laran/.pearrc System Configuration File Filename /Applications/ZendServer/etc/pear.conf me:ZendServer laran$
That’s wack. Why are my Pear libraries in /opt/local?
So, I changed those settings so that everything would be in /Applications/ZendServer
me:ZendServer laran$ sudo pear config-set php_dir /Applications/ZendServer/share/pear/PEAR config-set succeeded me:ZendServer laran$ sudo pear config-set data_dir /Applications/ZendServer/share/pear/PEAR/data config-set succeeded me:ZendServer laran$ sudo pear config-set temp_dir /Applications/ZendServer/share/pear/temp config-set succeeded me:ZendServer laran$ sudo pear config-set test_dir /Applications/ZendServer/share/pear/PEAR/tests config-set succeeded me:ZendServer laran$ sudo pear config-set bin_dir /Applications/ZendServer/bin config-set succeeded me:ZendServer laran$ sudo pear config-set download_dir /Applications/ZendServer/share/pear/temp/download config-set succeeded
Knowing that the Zend command line php executable is php-cli, not php, I made one last tweak:
me:ZendServer laran$ sudo pear config-set php_bin /Applications/ZendServer/bin/php-cli dyld: Library not loaded: /usr/local/postgresql-8.2.3/lib/libpq.5.dylib Referenced from: /Applications/ZendServer/bin/php Reason: image not found Trace/BPT trap
Doh! Looks like the damage was already done. So, I had to manually modify /Applications/ZendServer/bin/pear to use php-cli. Here’s what it looked like when I was done.
#!/bin/sh
# first find which PHP binary to use
if test "x$PHP_PEAR_PHP_BIN" != "x"; then
PHP="$PHP_PEAR_PHP_BIN"
else
if test "/Applications/ZendServer/bin/php" = '@'php_bin'@'; then
PHP=php-cli
else
PHP="/Applications/ZendServer/bin/php-cli"
fi
fi
# then look for the right pear include dir
if test "x$PHP_PEAR_INSTALL_DIR" != "x"; then
INCDIR=$PHP_PEAR_INSTALL_DIR
INCARG="-d include_path=$PHP_PEAR_INSTALL_DIR"
else
if test "/Applications/ZendServer/share/pear/PEAR" = '@'php_dir'@'; then
INCDIR=`dirname $0`
INCARG=""
else
INCDIR="/Applications/ZendServer/share/pear/PEAR"
INCARG="-d include_path=/Applications/ZendServer/share/pear/PEAR"
fi
fi
exec $PHP -C -q $INCARG -d output_buffering=1 -d variables_order=EGPCS -d open_basedir="" -d safe_mode=0 -d register_argc_argv="On" -d auto_prepend_file="" -d auto_append_file="" $INCDIR/pearcmd.php "$@"
The changes in there are on lines 8 and 10, I changed php to php-cli.
Now I can go back to change the Pear php_bin config properly:
me:ZendServer laran$ sudo pear config-set php_bin /Applications/ZendServer/bin/php-cli
Just to be sure, I checked the include_path in /Applications/ZendServer/etc/php.ini. Be sure that /Applications/ZendServer/share/pear/PEAR is on the path.
Restart apache with sudo /Applications/ZendServer/apache2/bin/apachectl restart
Lastly, any modules I’d installed while Pear was still configured to install them to /opt/local have to be re-installed.
And with that, I was ready to rock! Hope this helps.
I've got a masters degree in computer science and over 10 years of experience building web-based systems using Java/J2EE, Ruby, Rails and PHP. I'm a strong believer in the effectiveness of Agile Methods.
2 Comments
What will be best setup of Zend Server to enable CLI
What operating system are you running? The CLI environment is pretty different depending on the OS and how you have PHP installed etc.