Application:command line
From Surebert wiki
Contents |
Overview
You can use your application from the command line just as you can through the browser. This allows you to test output for quality control purposes, to cache data, to run scripts that are not mean for the browser. e.g. file management, backup tasks, etc
If request comes from command line Gateway::$request->agent == 'command line' otherwise it is set to the HTTP_USER_AGENT of the client.
You can also check the Gateway::$command_line boolean
Usage
- From the command line, cd into the public directory of your surebert framework application.
- Then either make the gateway.php executable and run it with the arguments required or load it using the PHP command, see below.
- The first argument is the path to the view that would be in the URL after the domain name e.g. http://example.com/user/report/visco
bash code
php gateway.php --request=/user/report/visco
Simulating Input
If you would like to simulate $_GET, $POST, $FILES, $_SERVER super globals create a file, say superglobals.php and add them to it.
bash code
//contents of superglobals.php $_SERVER['REMOTE_ADDR'] = '23.55.44.22'; $_GET = Array( 'cat' => 'dog', 'one' => 'two' ); $_POST['fff'] = 'ggg';
Then pass the path to the file as another argument to gateway.php, e.g.
bash code
php gateway.php --request=/user/report/visco --config=superglobals.php
Saving Output
To save output just send the contents of the output buffer to a file e.g.
bash code
php gateway.php --request=/user/report/visco --config=superglobals.php > output.txt
If you are trying to make cron jobs for your application see Framework:sb_Controller_Command_Line