I am using Zend Server CE on one of my servers and I’d like to do some PHP work from the CLI. Zend comes bundled with the PHP executable and an associated wrapper for the CLI, cleverly called php-cli. Among other things, this wrapper points to the correct php.ini file, which is key as it contains the information necessary to get PDO (DB abstraction) up and running.
The wrapper essentially contains this code:
Code:
#!/bin/sh
/opt/zend/bin/php -c /opt/zend/etc/php.ini $@
The problem I’m having comes from my attempt to use php-cli for scripting. I foolishly thought this would work:
Code:
#!/opt/zend/bin/php-cli
<?php
// Code goes here
But, of course, I was being stupid. Doing this fails to interpret the PHP at all and I receive this error:
Code:
./cli-test.php: line 2: ?php: No such file or directory
In an attempt to salvage what remained of my tarnished reputation, I tried to completely bypass the wrapper and mimic the same functionality with the executable by doing the following:
Code:
#!/opt/zend/bin/php –c /opt/zend/etc/php.ini
<?php
// Code goes here
Code interpretation works, but the ini file is not loaded (I know this because the DB drivers are not loaded). If, however, I try this from the command line in interactive mode as follows, the DB drivers are loaded and it works fine:
Code:
php –c /opt/zend/etc/php.ini
Any thoughts would be greatly appreciated as I’ve wrestled with this for quite a few hours now, the net effect of which has me questioning my career choice. I suppose the world always needs shepherds.