本文整理汇总了PHP中Dispatcher::Dispatch方法的典型用法代码示例。如果您正苦于以下问题:PHP Dispatcher::Dispatch方法的具体用法?PHP Dispatcher::Dispatch怎么用?PHP Dispatcher::Dispatch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dispatcher
的用法示例。
在下文中一共展示了Dispatcher::Dispatch方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Exception
<?php
/** @package Pizzaria Meveana */
/* GlobalConfig object contains all configuration information for the app */
include_once "_global_config.php";
include_once "_app_config.php";
@(include_once "_machine_config.php");
if (!GlobalConfig::$CONNECTION_SETTING) {
throw new Exception('GlobalConfig::$CONNECTION_SETTING is not configured. Are you missing _machine_config.php?');
}
/* require framework libs */
require_once "verysimple/Phreeze/Dispatcher.php";
// the global config is used for all dependency injection
$gc = GlobalConfig::GetInstance();
try {
Dispatcher::Dispatch($gc->GetPhreezer(), $gc->GetRenderEngine(), '', $gc->GetContext(), $gc->GetRouter());
} catch (exception $ex) {
// This is the global error handler which will be called in the event of
// uncaught errors. If the endpoint appears to be an API request then
// render it as JSON, otherwise attempt to render a friendly HTML page
$url = RequestUtil::GetCurrentURL();
$isApiRequest = strpos($url, 'api/') !== false;
if ($isApiRequest) {
$result = new stdClass();
$result->success = false;
$result->message = $ex->getMessage();
$result->data = $ex->getTraceAsString();
@header('HTTP/1.1 401 Unauthorized');
echo json_encode($result);
} else {
$gc->GetRenderEngine()->assign("message", $ex->getMessage());
示例2: uses
<?
include '../sys/sys.php';
uses('sys.app.config');
uses('sys.app.dispatcher');
uses('sys.utility.profiler');
Config::LoadEnvironment();
Profiler::Init();
// start buffering
ob_start();
// dispatch the request
Dispatcher::Dispatch(null,PATH_APP.'controller/', PATH_APP.'view/');
// flush the buffer
ob_flush();
示例3: Exception
// 定义常量
if (!defined("APP_PATH")) {
throw new Exception("System error : APP_PATH Undefined!");
}
if (!defined("APP_CORE")) {
define("APP_CORE", dirname(dirname(__FILE__)) . '/');
}
//只有这个是自动加载的
set_include_path(get_include_path() . PATH_SEPARATOR . APP_CORE . "lib/");
set_include_path(get_include_path() . PATH_SEPARATOR . APP_CORE . "include/");
set_include_path(get_include_path() . PATH_SEPARATOR . APP_CORE . "Parts/");
set_include_path(get_include_path() . PATH_SEPARATOR . APP_PATH . "Controller/");
set_include_path(get_include_path() . PATH_SEPARATOR . APP_PATH . "Model/");
set_include_path(get_include_path() . PATH_SEPARATOR . APP_PATH . "View/");
set_include_path(get_include_path() . PATH_SEPARATOR . APP_PATH . "Parts/");
//动态加载
function __autoload($object)
{
$objectfile = "{$object}.class.php";
if (strstr($objectfile, 'Controller') && $object != 'Controller' || strstr($objectfile, 'Model') && $object != 'Model') {
require_once "{$object}.php";
return;
}
require_once "{$objectfile}";
}
$GLOBALS['MAIN'] = (include 'Main.php');
include "Method.php";
$router = TUtils::Run("Router");
//数据输出
Dispatcher::Dispatch($router);
示例4: Array
require_once($_SERVER["DOCUMENT_ROOT"] . 'includes/framework/class.Config.php');
require_once($_SERVER["DOCUMENT_ROOT"] . 'includes/framework/class.Dispatcher.php');
$config = Array( "Backend" => "Mysql",
"Mysql_User" => "colorkey",
"Mysql_Password" => "gjaH81ia9",
"Mysql_Database" => "colorkey"
);
Config::singleton()->Load($config);
$dispatcher = new Dispatcher();
try
{
$dispatcher->Dispatch($_SERVER["REQUEST_URI"]);
} catch (ControllerNotFoundException $e)
{
}
exit;
set_time_limit(1000);
// example4: ?file=example4&cb=52&cr=34&a=60&b=100
// example: ?file=example&cb=81&cr=99&a=90&b=100
// example2: ?file=example2&cb=110&cr=46&a=90&b=100
// example3: ?file=example3&cb=115&cr=57&a=80&b=120
$file = "example";
示例5: set_include_path
<?php
/** @package HELLO WORLD */
set_include_path('./libs/' . PATH_SEPARATOR . './vendor/phreeze/phreeze/libs/' . PATH_SEPARATOR . get_include_path());
/* require framework libs */
require_once 'verysimple/Phreeze/Dispatcher.php';
require_once 'verysimple/Phreeze/ConnectionSetting.php';
require_once 'verysimple/Phreeze/SimpleRouter.php';
require_once 'verysimple/Phreeze/Phreezer.php';
require_once 'Controller/TestController.php';
$cs = new ConnectionSetting();
$cs->ConnectionString = "localhost:3306";
$cs->DBName = "hello_world";
$cs->Username = "benchmarkdbuser";
$cs->Password = "benchmarkdbpass";
$cs->Type = "MySQL";
$phreezer = new Phreezer($cs);
$route_map = array('GET:' => array('route' => 'Test.JSON'), 'GET:json' => array('route' => 'Test.JSON'), 'GET:db' => array('route' => 'Test.DB'), 'GET:query' => array('route' => 'Test.Query'), 'GET:fortunes' => array('route' => 'Test.Fortunes'), 'GET:updates' => array('route' => 'Test.Updates'), 'GET:plaintext' => array('route' => 'Test.PlainText'));
$router = new SimpleRouter('/', 'Test.JSON', $route_map);
Dispatcher::$FAST_LOOKUP = true;
Dispatcher::Dispatch($phreezer, null, '', null, $router);
示例6: create
public function create($id)
{
Dispatcher::Dispatch("/configs/put_index/$id",PATH_APP.'controller/',PATH_APP.'view/','txt');
}