2021 Update
The instructions in this blog post contain outdated paths and file names.
To learn the modern way to “save your fingers”—plus additional tips for setting up PHP on IBM i—refer to these two articles in our Open Source Documentation library.
In Batch PHP I showed how to call PHP from a command line. For example, with Zend Server 6 or 7 on IBM i, one would launch a PASE command line using the command CALL QP2TERM, or launch QShell using QSH, then type a command such as this:
|
/usr/local/zendsvr6/bin/php-cli myscript.php |
For those of us who use PHP-CLI often, the above command can be a finger-buster. Let’s shorten the path by creating a symbolic link:
|
cd /usr/bin ln -s /usr/local/zendsvr6/bin/php-cli phpc |
I created the symbolic link in /usr/bin, a directory that is likely to be in any user’s path.
Now try the shortened command:
To test the shortcut without a PHP script, use the -v switch, which requests version information (‘v’ for version) about your PHP installation.
The above command will return version information that starts out something like this:
|
PHP 5.3.6 (cli) (built: Apr 7 2011 09:37:14) Copyright (c) 1997-2011 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies with Zend Extension Manager v5.1, Copyright (c) 2003-2010, by Zend Techno logies - with Zend Data Cache v4.0, Copyright (c) 2004-2010, by Zend Technologie s [loaded] [licensed] [disabled] - with Zend Guard Loader v3.3, Copyright (c) 1998-2010, by Zend Technolog ies [loaded] [licensed] [enabled] - with Zend Job Queue v4.0, Copyright (c) 2004-2010, by Zend Technologies [loaded] [not licensed] [disabled] |
By creating a symbolic link to the PHP-CLI binary, practitioners of PHP can speed their work while saving their fingers.
For more about symbolic links, see my article Link up with QShell.