Created
August 15, 2013 21:33
-
-
Save wesleybliss/6245150 to your computer and use it in GitHub Desktop.
PHP CLI script starter - useful for quickly setting up command-line scripts.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Don't allow PHP to stop after global timeout setting | |
set_time_limit( 0 ); | |
// Increase memory limit | |
ini_set( 'memory_limit', '1024M' ); | |
// Remove output buffering | |
while ( ob_get_level() ) ob_end_clean(); | |
// Output buffers directly | |
ob_implicit_flush( true ); | |
// Custom error handling | |
//error_reporting( 0 ); | |
//function handleError( $errno, $errmsg, $filename, $linenum, $vars ) { | |
// stdError( | |
// '[' . $errno . '] Line #' . $linenum . | |
// PHP_EOL . $errmsg . PHP_EOL . ' in ' . $filename | |
// ); | |
//} | |
//$old_error_handler = set_error_handler( 'handleError' ); | |
// Only allow this script to be run via the command line | |
if ( strtoupper(PHP_SAPI) !== 'CLI' ) { | |
stdError( 'This script can only be run via the command line.', false ); | |
showUsage(); | |
exit( 1 ); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment