public function onWorkerStart($serv, $worker_id) { $this->application = new Yaf\Application(CONF_PATH . 'app.ini', 'product'); $this->application->bootstrap(); if ($worker_id >= $serv->setting['worker_num']) { cli_set_process_title("swoolehttp:task_worker"); } else { cli_set_process_title("swoolehttp:worker"); } //$serv->addtimer(300000); }
<?php /* +----------------------------------------------------------------------+ | Boom | +----------------------------------------------------------------------+ | This source file is subject to version 2.0 of the Apache license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.apache.org/licenses/LICENSE-2.0.html | | If you did not receive a copy of the Apache2.0 license and are unable| | to obtain it through the world-wide-web, please send a note to | | yiming_6weijun@163.com so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Weijun Lu <*****@*****.**> | +----------------------------------------------------------------------+ */ define('DS', DIRECTORY_SEPARATOR); define('APPLICATION_PATH', dirname(__DIR__) . DS . 'application'); $application = new \Yaf\Application(APPLICATION_PATH . '/conf/application.ini'); $application->bootstrap()->run();
<?php define("APP_PATH", realpath(dirname(__FILE__) . "/../")); define("PUBLIC_PATH", dirname(__FILE__)); $app = new \Yaf\Application(APP_PATH . "/config/application.ini"); $app->bootstrap()->run();
/** * 设置application */ public function setApplication() { $application = new \Yaf\Application(APPLICATION_PATH . "/conf/application.ini"); $application->bootstrap(); \Yaf\Registry::set('application', $application); }
<?php date_default_timezone_set("Asia/Shanghai"); define('ROOT_PATH', dirname(dirname(__FILE__))); define('PUBLIC_PATH', ROOT_PATH . '/public'); define('VENDOR_PATH', ROOT_PATH . '/vendor'); define('APPLICATION_PATH', ROOT_PATH . '/application'); define('APPLICATION_IS_CLI', php_sapi_name() == 'cli' ? true : false); require_once VENDOR_PATH . "/autoload.php"; $application = new \Yaf\Application(APPLICATION_PATH . "/config/application.ini", \Yaf\ENVIRON); $application->bootstrap(); if (!defined('APPLICATION_NOT_RUN')) { $application->run(); }
<?php ini_set('display_errors', 'on'); define("BASE_PATH", realpath(dirname(__FILE__) . "/../")); define("APPLICATION_PATH", realpath(dirname(__FILE__) . "/../application/")); define("LIBRARY_PATH", realpath(dirname(__FILE__) . "/../library/")); define("PUBLIC_PATH", dirname(__FILE__)); define("DS", '/'); require_once LIBRARY_PATH . DS . 'RDS' . DS . 'RDS_Network.php'; $rds_config = new Yaf\Config\Ini(APPLICATION_PATH . DS . 'configs' . DS . 'debug.ini'); $_DEBUGGER = new RDS_Network($_SERVER['REQUEST_URI'], $rds_config->rds->host, $rds_config->rds->port, true, false); $_PROFILER = $_DEBUGGER->newProfiler('GLOBAL_PROFILER'); $event = $_PROFILER->startEvent('Init application'); $app = new \Yaf\Application(APPLICATION_PATH . "/configs/application.ini"); $_PROFILER->endEvent($event); $event = $_PROFILER->startEvent('Bootstrap loader'); $app->bootstrap(); $_PROFILER->endEvent($event); $event = $_PROFILER->startEvent('Run application'); $app->run(); $_PROFILER->endEvent($event); $_PROFILER->end();
<?php /* example: php cli.php "request_uri=/command/account/index" */ define("APPLICATION_PATH", realpath(dirname(__FILE__) . '/../')); $app = new Yaf\Application(APPLICATION_PATH . '/conf/application.ini'); $app->bootstrap()->getDispatcher()->dispatch(new Yaf\Request\Simple());
<?php header("Content-Type: text/html;Charset=UTF-8"); define("APPLICATION_PATH", realpath(dirname(__FILE__) . '/..')); $application = new \Yaf\Application(APPLICATION_PATH . "/conf/application.ini"); require_once APPLICATION_PATH . '/application/Functions.php'; require_once APPLICATION_PATH . '/conf/Config.inc.php'; $response = $application->bootstrap()->run();
<?php /** * 执行外部脚本(不需要路由) */ define('APPLICATION_PATH', dirname(dirname(__FILE__))); require APPLICATION_PATH . '/vendor/autoload.php'; $application = new Yaf\Application(APPLICATION_PATH . "/conf/application.ini"); /** * 能自动加载所需要的Model或者类库 * 执行外部脚本(不需要路由) */ class Crontab { function runSomeJob() { // $m = new UserModel; // var_dump($m); } } $application->bootstrap()->execute(array(new Crontab(), 'runSomeJob'));