本文整理汇总了PHP中Yaf_Application::bootstrap方法的典型用法代码示例。如果您正苦于以下问题:PHP Yaf_Application::bootstrap方法的具体用法?PHP Yaf_Application::bootstrap怎么用?PHP Yaf_Application::bootstrap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Yaf_Application
的用法示例。
在下文中一共展示了Yaf_Application::bootstrap方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rpcserver_call
function rpcserver_call(swoole_process $worker)
{
define('APPLICATION_PATH', dirname(dirname(__DIR__)) . "/application");
define('THRIFT_DIR_PATH', dirname(APPLICATION_PATH) . "/thrift");
require_once THRIFT_DIR_PATH . "/Thrift/ClassLoader/ThriftClassLoader.php";
$loader = new Thrift\ClassLoader\ThriftClassLoader();
$loader->registerNamespace('Thrift', THRIFT_DIR_PATH);
$loader->registerNamespace('swoole', THRIFT_DIR_PATH);
$loader->registerNamespace('Bin', THRIFT_DIR_PATH);
$loader->registerDefinition('Bin', THRIFT_DIR_PATH);
$loader->register();
define('MYPATH', dirname(APPLICATION_PATH));
$application = new Yaf_Application(dirname(APPLICATION_PATH) . "/conf/application.ini");
$application->bootstrap();
$config_obj = Yaf_Registry::get("config");
$rpc_config = $config_obj->rpc->toArray();
define('SERVERIP', $rpc_config['ServerIp']);
define('SERVERPORT', $rpc_config['port']);
define('SERVERHOST', $rpc_config['host']);
$service = new Bin\rpc\Handler();
$processor = new Bin\rpc\rpcProcessor($service);
$socket_tranport = new Thrift\Server\TServerSocket(SERVERIP, SERVERPORT);
$out_factory = $in_factory = new Thrift\Factory\TFramedTransportFactory();
$out_protocol = $in_protocol = new Thrift\Factory\TBinaryProtocolFactory();
$server = new swoole\RpcServer($processor, $socket_tranport, $in_factory, $out_factory, $in_protocol, $out_protocol);
$server->serve();
}
示例2: __construct
/**
* init
*
* @return void
*/
public function __construct()
{
if (null === self::$_app) {
$app = new Yaf_Application(APP_PATH . '/config/application.ini');
self::$_app = $app->bootstrap();
}
parent::__construct();
}
示例3: hproseserver_call
function hproseserver_call(swoole_process $worker)
{
define('APPLICATION_PATH', dirname(__DIR__) . "/application");
define('MYPATH', dirname(APPLICATION_PATH));
$application = new Yaf_Application(dirname(APPLICATION_PATH) . "/conf/application.ini");
$application->bootstrap();
$config_obj = Yaf_Registry::get("config");
$hprose_config = $config_obj->hprose->toArray();
$server = new Server("tcp://" . $hprose_config['ServerIp'] . ":" . $hprose_config['port']);
$server->setErrorTypes(E_ALL);
$server->setDebugEnabled();
$server->addFunction('zys');
$server->start();
}
示例4: run
public function run($params = array())
{
$app = new Yaf_Application(APP_PATH . "/conf/application.ini");
$uri = Yaf_Dispatcher::getInstance()->getRequest()->getRequestUri();
list($tmp, $module, $controller, $action) = explode('/', $uri);
foreach ($params as $key => $value) {
Yaf_Dispatcher::getInstance()->getRequest()->setParam($key, $value);
}
$request = new Yaf_Request_Simple("Api", $module, $controller, $action, $params);
// $request = new Yaf_Request_Simple("Api", "User", "Index", "demo", array());
// Yaf_Dispatcher::getInstance()->getRequest()->setParam('uid',123456);
$response = $app->bootstrap()->getDispatcher()->returnResponse(TRUE)->dispatch($request);
// $response = $app->bootstrap()->getDispatcher()->dispatch($request);
return $response->getBody();
}
示例5: getConnection
protected function getConnection()
{
if ($this->__debug) {
echo __METHOD__ . "\n";
}
if (!isset(self::$__is_init)) {
$app = new Yaf_Application(PATH_RHEA_ETC . "application.ini", 'rhea');
$app->bootstrap();
self::$__is_init = true;
}
if (!self::$__conn) {
require_once PATH_RHEA_LIB . 'em_db.class.php';
$db = em_db::singleton();
$pdo = $db->get_connection();
self::$__conn = $this->createDefaultDBConnection($pdo, em_config::get('db_name'));
}
return self::$__conn;
}
示例6: realpath
<?php
ini_set('date.timezone', 'Asia/Shanghai');
define('ENV_CHANNEL', 'www');
define('ENV_SCENE', 'dev');
//define('ENV_SCENE', 'ga');
if (ENV_SCENE == 'dev') {
//报告运行时错误
error_reporting(E_ERROR | E_WARNING | E_PARSE);
}
define('ENV_DOMAIN', $_SERVER['HTTP_HOST']);
define("APP_PATH", realpath(__DIR__ . '/../app'));
define("LIB_PATH", realpath(__DIR__ . '/../library'));
try {
require_once LIB_PATH . '/loader.php';
$app = new Yaf_Application();
$app->bootstrap()->run();
} catch (Exception $e) {
echo $e->getMessage();
}
示例7: dirname
<?php
date_default_timezone_set('Asia/Chongqing');
define('APPLICATION_PATH', dirname(__FILE__) . '/../');
define('APP_PATH', dirname(__FILE__) . '/../');
if (!extension_loaded("yaf")) {
include APPLICATION_PATH . '/globals/framework/loader.php';
}
$application = new Yaf_Application(APPLICATION_PATH . "/conf/application.ini");
$application->bootstrap()->run();
示例8: dirname
<?php
/**
* [CodeJm!] Author CodeJm[codejm@163.com].
*
* cli 入口文件
* $Id: cli.php 2014-10-24 16:32:27 codejm $
*/
// 常用目录定义
//header("Content-type: text/html; charset=utf-8");
define("DS", '/');
define("PUBLIC_PATH", dirname(__FILE__) . DS);
define("BASE_PATH", realpath(dirname(__FILE__) . DS . '..') . DS);
define("APP_PATH", realpath(dirname(__FILE__) . DS . '..' . DS . 'application') . DS);
// composer
require_once BASE_PATH . 'vendor/autoload.php';
// 框架入口
$app = new Yaf_Application(APP_PATH . "conf/application.ini");
//$app->getDispatcher()->dispatch(new Yaf_Request_Simple());
$app->bootstrap()->getDispatcher()->dispatch(new Yaf_Request_Simple());
示例9: microtime
<?php
set_time_limit(0);
require_once 'conf_global.php';
$app = new Yaf_Application(PATH_RHEA_ETC . "application.ini", 'rhea');
$app->bootstrap();
require_once PATH_RHEA_LIB . 'em_certificate.class.php';
$cert = new em_certificate();
$pkey_pair_num = 100;
require_once PATH_RHEA_LIB . 'member/em_member_operator_pkey.class.php';
/*
// 20-21 sec
$t = microtime(true);
for ($i = 1, $c = $pkey_pair_num; $i <= $c; $i++) {
$cert->create_private();
$pub_key = $cert->get_pubkey();
$priv_key = $cert->get_privkey();
printf("+Ok, Set up %d key pair succ!\r", $i);
}
echo "\n";
echo microtime(true)-$t;
echo "\n";
*/
$t = 0;
for ($i = 1, $c = $pkey_pair_num; $i <= $c; $i++) {
$t1 = microtime(true);
$cert->create_private();
$cert->free();
$t2 = microtime(true);
$t += $t2 - $t1;
printf("%d\r", $i);
示例10: dirname
<?php
define('APPLICATION_PATH', dirname(dirname(__DIR__)) . "/application");
define('THRIFT_DIR_PATH', dirname(APPLICATION_PATH) . "/thrift");
require_once THRIFT_DIR_PATH . "/Thrift/ClassLoader/ThriftClassLoader.php";
$loader = new Thrift\ClassLoader\ThriftClassLoader();
$loader->registerNamespace('Thrift', THRIFT_DIR_PATH);
$loader->registerNamespace('swoole', THRIFT_DIR_PATH);
$loader->registerNamespace('Bin', THRIFT_DIR_PATH);
$loader->registerDefinition('Bin', THRIFT_DIR_PATH);
$loader->register();
$application = new Yaf_Application(dirname(APPLICATION_PATH) . "/conf/application.ini");
$application->bootstrap();
$config_obj = Yaf_Registry::get("config");
$rpc_config = $config_obj->rpc->toArray();
define('SERVERIP', $rpc_config['ServerIp']);
define('SERVERPORT', $rpc_config['port']);
define('SERVERHOST', $rpc_config['host']);
$service = new Bin\rpc\Handler();
$processor = new Bin\rpc\rpcProcessor($service);
$socket_tranport = new Thrift\Server\TServerSocket(SERVERIP, SERVERPORT);
$out_factory = $in_factory = new Thrift\Factory\TFramedTransportFactory();
$out_protocol = $in_protocol = new Thrift\Factory\TBinaryProtocolFactory();
$server = new swoole\Server($processor, $socket_tranport, $in_factory, $out_factory, $in_protocol, $out_protocol);
$server->serve();
示例11: dirname
<?php
/* INI配置文件支持常量替换 */
define("APPLICATION_PATH", dirname(__FILE__) . "/application");
/**
* 默认的, Yaf_Application将会读取配置文件中在php.ini中设置的ap.environ的配置节
* 另外在配置文件中, 可以替换PHP的常量, 比如此处的APPLICATION_PATH
*/
$application = new Yaf_Application("conf/application.ini");
/* 如果打开flushIstantly, 则视图渲染结果会直接发送给请求端
* 而不会写入Response对象
*/
//$application->getDispatcher()->flushInstantly(TRUE);
/* 如果没有关闭自动response(通过Yaf_Dispatcher::getInstance()->returnResponse(TRUE)),
* 则$response会被自动输出, 此处也不需要再次输出Response
*/
$response = $application->bootstrap()->run();
示例12: bootstrap
/**
* 启动程序
*
* @author mrmsl <msl-138@163.com>
* @date 2013-01-22 15:06:16
*
* @return void 无返回值
*/
public function bootstrap()
{
ob_get_level() != 0 && ob_end_clean();
header('content-type: text/html; charset=utf-8');
if (APP_DEBUG || !is_file(RUNTIME_FILE)) {
$this->_buildRuntimeFile();
if (APP_DEBUG && is_file(RUNTIME_FILE)) {
unlink(RUNTIME_FILE);
}
} else {
require RUNTIME_FILE;
}
$app = new Yaf_Application(CONF_FILE);
$app->getDispatcher()->registerPlugin(new BootstrapPlugin());
$app->bootstrap()->run();
}
示例13: define
if (isset($_GET['debug'])) {
xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
define('START_TIME', microtime(true));
define('START_MEMORY_USAGE', memory_get_usage());
}
if (phpversion() >= "5.3") {
define("APP_PATH", __DIR__);
} else {
define("APP_PATH", dirname(__FILE__));
}
$app = new Yaf_Application(APP_PATH . "/conf/application.ini");
$app->bootstrap() //call bootstrap methods defined in Bootstrap.php
->run();
$xhprof_data = xhprof_disable();
if (!isset($_GET['debug'])) {
die();
}
echo "Page rendered in <b>"
. round((microtime(true) - START_TIME), 5) * 1000 ." ms</b>, taking <b>"
. round((memory_get_usage() - START_MEMORY_USAGE) / 1024, 2) ." KB</b>";
$f = get_included_files();
echo ", include files: ".count($f);
$XHPROF_ROOT = realpath(dirname(__FILE__) .'/..');