Previously I mentioned that I use the Zend Framework's
Zend_Service_Amazon component within CLI scripts. While it's indeed possible to use Zend Framework components outside of the context of a Zend Framework application, I actually prefer to use Zend Framework-integrated CLI scripts
in conjunction with an existing Zend Framework-driven website. This allows me to take advantage of the website's existing
application.ini file when running the CLI scripts, thereby keeping my application code
DRY.
Zend Framework-integrated CLI scripts behave identically to a traditional Web-based Zend Framework application, requiring the application resources to be initialized with each script invocation. This is done using a custom bootstrap file, which is executed before the CLI script. Mine looks like this (named cli.php and placed in the application's public directory):
With the custom bootstrap file in place, you can then proceed using Zend Framework components and other application resources within your CLI scripts:
Are you using the PHP CLI for any custom command-line tasks? If so, tell us about them in the comments!