当前位置: 首页>>代码示例>>PHP>>正文


PHP Router::run方法代码示例

本文整理汇总了PHP中Router::run方法的典型用法代码示例。如果您正苦于以下问题:PHP Router::run方法的具体用法?PHP Router::run怎么用?PHP Router::run使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Router的用法示例。


在下文中一共展示了Router::run方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testMatchingCheckesHost

 public function testMatchingCheckesHost()
 {
     $this->setExpectedException('Vexillum\\Http\\PageNotFoundException');
     $route = Router::get('/apath', function () {
     }, array('host' => 'localyacht.dev'));
     Router::run('GET', 'localboat.dev', '/apath');
 }
开发者ID:kiasaki,项目名称:vexillum,代码行数:7,代码来源:RouterTest.php

示例2: route

 public function route($model, $form, $fieldName, $fieldType, $path)
 {
     $field = $form->fields()->{$fieldName};
     if (!$field or $field->type() !== $fieldType) {
         throw new Exception('Invalid field');
     }
     $routes = $field->routes();
     $router = new Router($routes);
     if ($route = $router->run($path)) {
         if (is_callable($route->action()) and is_a($route->action(), 'Closure')) {
             return call($route->action(), $route->arguments());
         } else {
             $controllerFile = $field->root() . DS . 'controller.php';
             $controllerName = $fieldType . 'FieldController';
             if (!file_exists($controllerFile)) {
                 throw new Exception(l('fields.error.missing.controller'));
             }
             require_once $controllerFile;
             if (!class_exists($controllerName)) {
                 throw new Exception(l('fields.error.missing.class'));
             }
             $controller = new $controllerName($model, $field);
             return call(array($controller, $route->action()), $route->arguments());
         }
     } else {
         throw new Exception(l('fields.error.route.invalid'));
     }
 }
开发者ID:irenehilber,项目名称:kirby-base,代码行数:28,代码来源:field.php

示例3: run

 public static function run()
 {
     Connection::connect();
     Session::start();
     Router::run();
     Connection::disconnect();
 }
开发者ID:albertomoreno,项目名称:web-newspaper,代码行数:7,代码来源:App.php

示例4: request

 public function request()
 {
     $request = Router::run();
     $matches = [];
     foreach ($request['matches'] as $k => $v) {
         if (is_int($k)) {
             continue;
         }
         $matches[$k] = $v;
     }
     unset($request['matches'], $request['pattern']);
     $request = array_merge($request, $matches);
     foreach ($request as $k => $v) {
         $request[$k] = $v;
     }
     $request['action'] = isset($request['action']) && !empty($request['action']) ? $request['action'] : 'index';
     // set default action
     if (!empty($_REQUEST)) {
         $request['params'] = $_REQUEST;
     }
     if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
         // check if ajax call
         $request['ajax'] = true;
     }
     return $request;
 }
开发者ID:tiger154,项目名称:prototype,代码行数:26,代码来源:Core.php

示例5: run

 public function run()
 {
     // 添加router的配置处理
     if ($routerRules = $this->get('routers')) {
         Router::set($routerRules);
     }
     Router::run();
 }
开发者ID:willsky,项目名称:quick,代码行数:8,代码来源:app.php

示例6: testRunWithError

 /**
  * @covers Zepto\Router::run()
  * @covers Zepto\Router::match()
  * @covers Zepto\Router::error()
  */
 public function testRunWithError()
 {
     $_SERVER['REQUEST_URL'] = '/zepto/failure';
     $_SERVER['REQUEST_URI'] = '/zepto/failure';
     $this->mock_request->expects($this->any())->method('getPathInfo')->will($this->returnValue('/failure'));
     $this->router->get('/failure', function () {
         throw new \Exception('Proving another point');
     });
     $this->assertFalse($this->router->run());
     $this->assertEquals(500, $this->router->current_http_status());
 }
开发者ID:hassankhan,项目名称:sonic,代码行数:16,代码来源:RouterTest.php

示例7: call_action

 private function call_action($uri, $method)
 {
     global $map;
     $map = new Router($uri);
     include 'config/routes.php';
     try {
         $this->controller = $map->run($method);
     } catch (RedirectException $ex) {
         $this->handle_redirect_exception($ex);
     }
     if (count($this->expected_redirects) > 0) {
         $this->fail("Didn't redirect as expected");
     }
 }
开发者ID:szchkt,项目名称:leaklog-web,代码行数:14,代码来源:controller_test_case.php

示例8: handleError

 /**
  * Register or run error
  *
  * @param string   $type
  * @param callable $route
  * @throws \InvalidArgumentException
  * @throws \Exception
  */
 public function handleError($type, $route = null)
 {
     if (!isset($this->injectors['errors'][$type])) {
         throw new \InvalidArgumentException('Unknown error type "' . $type . '" to call');
     }
     if (is_string($route) && class_exists($route) || $route instanceof \Closure) {
         // Set error handle
         $this->injectors['errors'][$type][2] = $route;
     } else {
         if (!$this->injectors['exception'] && $route instanceof \Exception) {
             // Not handle exception and throw it
             throw $route;
         } else {
             // Clean the output buffer
             ob_get_level() && ob_clean();
             // Check handle route and run it
             if (empty($this->injectors['errors'][$type][2]) || !$this->router->run($this->injectors['errors'][$type][2], array('error' => array('type' => $type, 'error' => $route, 'message' => $this->injectors['errors'][$type])))) {
                 /**
                  * Get error information
                  */
                 $error = $route instanceof \Exception ? $route : null;
                 $title = $error ? $error->getMessage() : $this->injectors['errors'][$type][1];
                 $code = $this->injectors['errors'][$type][0];
                 $message = $route ? $error ? $error->getFile() . ' [' . $error->getLine() . ']' : (string) $route : '';
                 if ($this->injectors['cli']) {
                     // Cli error show
                     $this->halt($code, Console::text('[' . $title . '] ' . ($message ? $message : '"' . $this->input->path() . '"') . ' ', 'redbg') . "\n" . ($this->injectors['debug'] && $error ? Console::text("\n[Error]\n", "yellow") . $error . "\n" : ''));
                 } else {
                     // Http error show
                     $this->output->status($this->injectors['errors'][$type][0]);
                     if ($this->injectors['debug']) {
                         // Debug error show
                         $this->renderView('Error', array('title' => $title, 'message' => $message ? $message : 'Could not ' . $this->input->method() . ' ' . $this->input->path(), 'stacks' => $this->injectors['debug'] && $error ? $error->getTraceAsString() : null));
                     } else {
                         // Normal error show
                         $this->renderView('Error', array('title' => $title, 'message' => $message ? $message : 'Could not ' . $this->input->method() . ' ' . $this->input->path()));
                     }
                     $this->stop();
                 }
             }
         }
     }
 }
开发者ID:pagon,项目名称:framework,代码行数:51,代码来源:App.php

示例9: handleError

 /**
  * Register or run error
  *
  * @param string   $type
  * @param callable $route
  * @throws \InvalidArgumentException
  */
 public function handleError($type, $route = null)
 {
     if (!isset($this->injectors['errors'][$type])) {
         throw new \InvalidArgumentException('Unknown error type "' . $type . '" to call');
     }
     if (is_string($route) && is_subclass_of($route, Route::_CLASS_, true) || $route instanceof \Closure) {
         $this->injectors['errors'][$type][2] = $route;
     } else {
         ob_get_level() && ob_clean();
         ob_start();
         if (empty($this->injectors['errors'][$type][2]) || !$this->router->run($this->injectors['errors'][$type][2], array('error' => array('type' => $type, 'error' => $route, 'message' => $this->injectors['errors'][$type])))) {
             if ($this->injectors['cli']) {
                 $this->halt($this->injectors['errors'][$type][0], $this->injectors['errors'][$type][1]);
             } else {
                 $this->output->status($this->injectors['errors'][$type][0]);
                 $this->render('pagon/views/error.php', array('title' => $this->injectors['errors'][$type][1], 'message' => $route ? $route instanceof \Exception ? $route->getMessage() : (string) $route : 'Could not ' . $this->input->method() . ' ' . $this->input->path()));
                 $this->stop();
             }
         }
     }
 }
开发者ID:pagon,项目名称:core,代码行数:28,代码来源:App.php

示例10: response

 public function response()
 {
     // this will trigger the configuration
     $site = $this->site();
     $router = new Router($this->routes());
     $route = $router->run($this->path());
     // check for a valid route
     if (is_null($route)) {
         header::status('500');
         header::type('json');
         die(json_encode(array('status' => 'error', 'message' => 'Invalid route or request method')));
     }
     $response = call($route->action(), $route->arguments());
     if (is_string($response)) {
         $this->response = static::render(page($response));
     } else {
         if (is_array($response)) {
             $this->response = static::render(page($response[0]), $response[1]);
         } else {
             if (is_a($response, 'Response')) {
                 $this->response = $response;
             } else {
                 if (is_a($response, 'Page')) {
                     $this->response = static::render($response);
                 } else {
                     $this->response = null;
                 }
             }
         }
     }
     return $this->response;
 }
开发者ID:chrishiam,项目名称:LVSL,代码行数:32,代码来源:kirby.php

示例11: exit

<?php

if (!defined('__ROOT__')) {
    exit('Sorry,Please from entry!');
}
/**
 * init 入口引入文件
 * 项目自动初始化文件
 * 创建时间:2014-08-08 14:56 PGF
 */
Loader::core('Debug');
//加载DEBUG类
Debug::start();
//程序开始
Loader::func('Base');
//加载基础全局函数
Loader::core('Cache');
//加载缓存处理类
Cache::init();
//初始化缓存类
//向日志中添加已经加载的Loader
Debug::add(__ROOT__ . Config::config('core_dir') . '/bases/' . 'Loader.class.php', 1);
Loader::core('Router');
//加载Router
Router::run();
//Router运行
Debug::stop();
//程序结束
//====================    END Initialize.php      ========================//
开发者ID:pgfeng,项目名称:GFPHP,代码行数:29,代码来源:Initialize.php

示例12: builderForm

<?php

/**
 * Builder Plugin
 *
 * @author Tim Ötting <email@tim-oetting.de>
 * @version 0.9
 */
$router = new Router(array(array('pattern' => 'views/editor/builder2/(:all)/(:any)/(:any)/(:any)', 'action' => 'builderForm', 'filter' => 'auth', 'method' => 'POST|GET', 'modal' => true)));
if ($route = $router->run()) {
    call($route->action(), $route->arguments());
    exit;
}
function builderForm($id, $fieldName, $fieldsetName, $context)
{
    $kirby = kirby();
    $kirby->extensions();
    $kirby->plugins();
    $root = $kirby->roots->index . DS . 'panel';
    $panel = new Panel($kirby, $root);
    $panel->i18n();
    $roots = new Panel\Roots($panel, $root);
    $site = $kirby->site();
    $page = empty($id) ? site() : page($id);
    if (!$page) {
        throw new Exception('The page could not be found');
    }
    $blueprint = blueprint::find($page);
    $field = null;
    $fields = $context == 'file' ? $blueprint->files()->fields() : $blueprint->fields();
    // make sure to get fields by case insensitive field names
开发者ID:cnoss,项目名称:fubix,代码行数:31,代码来源:builder.php

示例13: array

{
    $flash = $_SESSION['flash'];
    if (!$init_only) {
        session_destroy();
        session_start();
    }
    if (!array_key_exists('flash', $_SESSION)) {
        $_SESSION['flash'] = is_array($flash) ? $flash : array();
    }
}
session_restart(true);
// Helpers
require_once 'lib/system/helpers.php';
require_once 'lib/system/html_helpers.php';
if (file_exists(MODULES_PATH . 'main/application/application_helpers.php')) {
    include MODULES_PATH . 'main/application/application_helpers.php';
}
// Models
require_once 'lib/system/model.php';
// Controllers
require_once 'lib/system/controller.php';
if (!file_exists(MODULES_PATH . 'main/application/application_controller.php')) {
    error();
}
include MODULES_PATH . 'main/application/application_controller.php';
// Router
require_once 'lib/system/router.php';
$map = new Router($_GET['uri']);
include 'config/routes.php';
$map->run();
开发者ID:szchkt,项目名称:leaklog-web,代码行数:30,代码来源:run.php

示例14: dirname

<?php

//Frong Controller
//1. Общие настройки**************
ini_set('display_errors', 1);
error_reporting(E_ALL);
session_start();
//2. Подключение файлов системы**************
define('ROOT', dirname(__FILE__));
require_once ROOT . '/components/Autoload.php';
//3. Подключение к Базе Данных
//4. Вызов Router
$rou = new Router();
$rou->run();
开发者ID:Constantinehub,项目名称:first_project,代码行数:14,代码来源:index.php

示例15: __construct

header('Access-Control-Allow-Origin: *');
$_identifier = '[\\w\\d_-\\s]+';
$_number = '\\d+';
$r = new Router();
$r->map("", array("controller" => "serverinfo", "action" => "hello"));
$r->map("root.xml", array("controller" => "TileMapService", "action" => "root"));
$r->map("1.0.0", array("controller" => "TileMapService", "action" => "service"));
$r->map("1.0.0/:layer", array("controller" => "TileMapService", "action" => "resource"), array("layer" => $_identifier));
$r->map("1.0.0/:layer/:z/:x/:y.:ext", array("controller" => "maptile", "action" => "serveTmsTile"), array("layer" => $_identifier, "x" => $_number, "y" => $_number, "z" => $_number, "ext" => "(png|jpg|jpeg|json)"));
$r->map(":layer/:z/:x/:y.:ext", array("controller" => "maptile", "action" => "serveTile"), array("layer" => $_identifier, "x" => $_number, "y" => $_number, "z" => $_number, "ext" => "(png|jpg|jpeg|json)"));
$r->map(":layer/:z/:x/:y.:ext\\?:argument=:callback", array("controller" => "maptile", "action" => "serveTile"), array("layer" => $_identifier, "x" => $_number, "y" => $_number, "z" => $_number, "ext" => "(json|jsonp)", "argument" => $_identifier, "callback" => $_identifier));
$r->map(":layer/:z/:x/:y.grid.:ext", array("controller" => "maptile", "action" => "serveTile"), array("layer" => $_identifier, "x" => $_number, "y" => $_number, "z" => $_number, "ext" => "(json|jsonp)", "argument" => $_identifier, "callback" => $_identifier));
$r->map(":layer/:z/:x/:y.grid.:ext\\?:argument=:callback", array("controller" => "maptile", "action" => "serveTile"), array("layer" => $_identifier, "x" => $_number, "y" => $_number, "z" => $_number, "ext" => "(json|jsonp)", "argument" => $_identifier, "callback" => $_identifier));
$r->map(":layer.tilejson", array("controller" => "maptile", "action" => "tilejson"), array("layer" => $_identifier));
$r->map(":layer.tilejsonp\\?:argument=:callback", array("controller" => "maptile", "action" => "tilejson"), array("layer" => $_identifier, "argument" => $_identifier, "callback" => $_identifier));
$r->run();
class BaseClass
{
    protected $layer;
    protected $db;
    public function __construct()
    {
    }
    protected function getMBTilesName()
    {
        return $this->layer . ".mbtiles";
    }
    protected function openDB()
    {
        $filename = $this->getMBTilesName();
        if (file_exists($filename)) {
开发者ID:striblab,项目名称:startribune_dataviz,代码行数:31,代码来源:tileserver.php


注:本文中的Router::run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。