Gene支持命令行方式运行,方便编写定时运行任务;
Cli需要在运行前指定加载目录,同时获取Cli参数传递给运行函数。 参数一:路由类型传递get; 参数二:URI传递获取的命令行参数;
<?php
define('APP_ROOT', dirname(__dir__) . '/application');
$uri = '';
if (isset($_SERVER['argv'][1])) {
$uri = $_SERVER['argv'][1];
} else {
exit('This script is run as CLI with no path?');
}
$app = \Gene\Application::getInstance();
$app
->autoload(APP_ROOT)
->load("router.ini.php")
->load("config.ini.php")
->run('get', $uri);