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


PHP Router::execute方法代码示例

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


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

示例1: __construct

 /**
  * @param Base $base
  * @internal param $config
  */
 function __construct($base)
 {
     $this->route_callback = Router::execute($base);
     if (is_callable($this->route_callback[0])) {
         call_user_func_array($this->route_callback[0], $this->route_callback[1]);
     } else {
         $base->load->controller($this->route_callback[0], array(), $this->route_callback[1], $this->route_callback[2]);
     }
 }
开发者ID:ajaxtown,项目名称:eaglehorn_framework,代码行数:13,代码来源:bootstrap.php

示例2: router

 /**
  * Figure out where the user is trying to get to and route them to the
  * appropriate controller/action.
  */
 function router()
 {
     // Create a new Router instance.
     $r = new Router();
     // Configure the routes, where the user should go when they access the
     // specified URL structures. Default controller and action is set in the
     // config.php file.
     $r->map('/', array('controller' => ROUTER_DEFAULT_CONTROLLER, 'action' => ROUTER_DEFAULT_ACTION));
     $r->map('/user', array('controller' => 'user', 'action' => 'index'));
     $r->map('/login', array('controller' => 'user', 'action' => 'login'));
     $r->map('/logout', array('controller' => 'user', 'action' => 'logout'));
     $r->map('/signup', array('controller' => 'user', 'action' => 'register'));
     $r->map('/users/:id', array('controller' => 'users'), array('id' => '[\\d]{1,8}'));
     // Load instructions for basic routing and send the user on their way!
     $r->default_routes();
     $r->execute();
     // Extracting info about where the user is headed, in order to match the
     // URL with the correct controllers/actions.
     $controller = $r->controller;
     $model = $r->controller_name;
     $action = $r->action;
     $id = $r->id;
     $params = $r->params;
     // Returns an array(...)
     $matched = $r->route_found;
     // Bool, where True is if a route was found.
     if ($matched) {
         // If going to a site page, treat it in special manner, otherwise load
         // the appropriate controller/action and pass in the variables and
         // parameters specified by the URL.
         if ($controller == "site") {
             $site = new Site();
             $site->load_page($action);
         } elseif (file_exists(LIB_DIR . '/controllers/' . $controller . '.php')) {
             ${$controller} = new $model();
             if (method_exists(${$controller}, $action)) {
                 ${$controller}->{$action}($id, $params[0], $params[1]);
             } else {
                 Site::load_page('error');
             }
         } else {
             Site::load_page('error');
         }
     } else {
         Site::load_page('home');
     }
 }
开发者ID:JTGMAGIC,项目名称:jQuery-Mobile-PHP-MVC,代码行数:51,代码来源:app.php

示例3: catch

    if (is_file(APP_PATH . "extensions/helpers/{$class}.php")) {
        return include APP_PATH . "extensions/helpers/{$class}.php";
    }
    if (is_file(CORE_PATH . "extensions/helpers/{$class}.php")) {
        return include CORE_PATH . "extensions/helpers/{$class}.php";
    }
    if (is_file(APP_PATH . "libs/{$class}.php")) {
        return include APP_PATH . "libs/{$class}.php";
    }
    if (is_file(CORE_PATH . "libs/{$class}/{$class}.php")) {
        return include CORE_PATH . "libs/{$class}/{$class}.php";
    }
    if ($class == 'kumbia_exception') {
        include CORE_PATH . 'kumbia/kumbia_exception.php';
    }
}
// @see Router
require CORE_PATH . 'kumbia/router.php';
// @see Controller
require APP_PATH . 'libs/app_controller.php';
// @see KumbiaView
require APP_PATH . 'libs/view.php';
// Ejecuta el request
try {
    // Dispatch y renderiza la vista
    View::render(Router::execute($url), $url);
} catch (KumbiaException $e) {
    KumbiaException::handle_exception($e);
}
// Fin del request
exit;
开发者ID:eldister,项目名称:sistem-gestion-documental,代码行数:31,代码来源:bootstrap.php

示例4: array_keys

$get = array_keys($_GET);
$route = array_shift($get);
/** Autoloader */
spl_autoload_register(function ($class) {
    $path = str_replace(__NAMESPACE__ . '\\', '', $class);
    $path = str_replace('\\', '/', $path);
    require_once $path . '.php';
});
Model::init();
//Router::route('install', ['Blog\AbstractController', 'install']);
//
Router::route('posts', ['Blog\\Controller\\Front', 'posts']);
//Router::route('edit/post/(\d+)', ['Blog\Controller\Front', 'form']);
//Router::route('delete/post/(\d+)', ['Blog\Controller\Front', 'delete']);
//Router::route('edit/post/', ['Blog\Controller\Front', 'form']);
//Router::route('new/post', ['Blog\Controller\Front', 'form']);
//
//Router::route('users', ['Blog\Controller\User', 'index']);
//Router::route('delete/user/(\d+)', ['Blog\Controller\User', 'delete']);
//Router::route('new/user', ['Blog\Controller\User', 'form']);
//Router::route('edit/user/', ['Blog\Controller\User', 'form']);
//Router::route('edit/user/(\d+)', ['Blog\Controller\User', 'form']);
Router::route('([a-z]+)/(index)');
Router::route('([a-z]+)/(single)/(\\d*)');
Router::route('([a-z]+)/(delete)/(\\d+)');
Router::route('([a-z]+)/(insert)');
Router::route('([a-z]+)/(edit)/(\\d*)');
Router::route('([a-z]+)/(save)/(\\d*)');
Router::execute($_SERVER['QUERY_STRING']);
开发者ID:kuridza,项目名称:blog,代码行数:29,代码来源:index.php

示例5: define

<?php

require __DIR__ . '/check_setup.php';
require __DIR__ . '/controllers/base.php';
require __DIR__ . '/lib/router.php';
if (file_exists('config.php')) {
    require 'config.php';
}
// Auto-refresh frequency in seconds for the public board view
defined('AUTO_REFRESH_DURATION') or define('AUTO_REFRESH_DURATION', 60);
$router = new Router();
$router->execute();
开发者ID:ashwinrayaprolu1984,项目名称:kanboard,代码行数:12,代码来源:index.php

示例6: index

 public function index()
 {
     Router::execute("dashboard/");
 }
开发者ID:jaimeirazabal1,项目名称:rtf_con_kumbiaphp,代码行数:4,代码来源:index_controller.php

示例7: Router

<?php

require_once __DIR__ . '/utils/Router.class.php';
require_once __DIR__ . '/controllers/Controller.class.php';
require_once __DIR__ . '/controllers/UserController.class.php';
require_once __DIR__ . '/controllers/BlogListController.class.php';
require_once __DIR__ . '/controllers/BlogController.class.php';
require_once __DIR__ . '/controllers/PostListController.class.php';
require_once __DIR__ . '/controllers/PostController.class.php';
require_once __DIR__ . '/controllers/CommentListController.class.php';
require_once __DIR__ . '/controllers/CommentController.class.php';
require_once __DIR__ . '/controllers/CategoryListController.class.php';
require_once __DIR__ . '/controllers/CategoryController.class.php';
require_once __DIR__ . '/controllers/RegisterController.class.php';
require_once __DIR__ . '/controllers/LoginController.class.php';
$router = new Router('\\/api\\/v1');
$router->route('\\/users\\/(\\d+)', 'UserController::handle');
$router->route('\\/blogs', 'BlogListController::handle');
$router->route('\\/blogs\\/(\\d+)', 'BlogController::handle');
$router->route('\\/posts', 'PostListController::handle');
$router->route('\\/posts\\/(\\d+)', 'PostController::handle');
$router->route('\\/comments', 'CommentListController::handle');
$router->route('\\/comments\\/(\\d+)', 'CommentController::handle');
$router->route('\\/categories', 'CategoryListController::handle');
$router->route('\\/categories\\/(\\d+)', 'CategoryController::handle');
$router->route('\\/register', 'RegisterController::handle');
$router->route('\\/login', 'LoginController::handle');
if (isset($_SERVER['REDIRECT_URL'])) {
    $router->execute(explode('?', $_SERVER['REDIRECT_URL'])[0]);
}
Controller::response(array(), 404, 'Route not found');
开发者ID:anehx,项目名称:blog,代码行数:31,代码来源:index.php

示例8: define

<?php

define('DS', DIRECTORY_SEPARATOR);
define('ROOT', dirname(dirname(__FILE__)));
$url = empty($_GET['url']) ? 'index' : $_GET['url'];
require_once ROOT . DS . 'app' . DS . 'lib' . DS . 'init.php';
//  Criando as rotas dinamicamente
Router::route("/(\\w+)/?(\\w+)?/?(\\w+)?", function ($param0, $param1 = '', $param2 = '') {
    $params = func_get_args();
    $modelName = ucwords(strtolower($params[0]));
    try {
        $model = new $modelName();
        $controller = new Controller($model, $params[1]);
        $controller->{$params[1]}();
    } catch (Throwable $t) {
        // echo $t->getMessage();
        // var_dump($params);
    }
    $view = new View($model, "base");
    $view->render();
    return;
});
try {
    Router::execute("/" . $url);
} catch (Exception $e) {
    echo $e->getMessage();
}
开发者ID:robertgeb,项目名称:zoacomphp,代码行数:27,代码来源:index.php

示例9: process

 public function process($request = array(), $params = array())
 {
     $query_string = $request['PATH'];
     return $this->router->execute($query_string, $request, $params);
 }
开发者ID:chobie,项目名称:chatwork-api-client,代码行数:5,代码来源:Kernel.php

示例10: error_reporting

<?php

// PHP 5.5.10
error_reporting(0);
define('BASEPATH', __DIR__);
// Подключаем роутер, он будет обрабатывать запросы,
// назначать им методы приложения или отображать страницу
// 404 для некооректных запросов
require_once BASEPATH . '/app/core/router.php';
// Подключаем контроллер проекта
require_once BASEPATH . '/app/draw.php';
// Инициализируем класс проекта (контроллер)
$draw = new Draw();
// Назначаем роуты приложения
Router::route('', 'imgList');
Router::route('list', 'imgList');
Router::route('edit', 'imgEdit');
Router::route('create', 'imgEdit');
Router::route('insert', 'ajaxInsert');
Router::route('update', 'ajaxUpdate');
// Запускаем роутер для нашего приложения
Router::execute($draw, $_GET['action']);
开发者ID:dataloft,项目名称:draw-canvas,代码行数:22,代码来源:index.php

示例11: autoloader

session_start();
// includes the system routes. Define your own routes in this file
include ROOT_PATH . '/config/routes.php';
/**
 * Standard framework autoloader
 * @param string $className
 */
function autoloader($className)
{
    // controller autoloading
    if (strlen($className) > 10 && substr($className, -10) == 'Controller') {
        if (file_exists(ROOT_PATH . '/app/controllers/' . $className . '.php') == 1) {
            require_once ROOT_PATH . '/app/controllers/' . $className . '.php';
        }
    } else {
        if (file_exists(CMS_PATH . $className . '.php')) {
            require_once CMS_PATH . $className . '.php';
        } else {
            if (file_exists(ROOT_PATH . '/lib/' . $className . '.php')) {
                require_once ROOT_PATH . '/lib/' . $className . '.php';
            } else {
                require_once ROOT_PATH . '/app/models/' . $className . '.php';
            }
        }
    }
}
// activates the autoloader
spl_autoload_register('autoloader');
$router = new Router();
$router->execute($routes);
开发者ID:mukkoju,项目名称:php-mvc-base,代码行数:30,代码来源:index.php

示例12: Router

require_once 'environment.default.php';
session_start();
include 'lib/redis/RedisClient.php';
include 'lib/redis/Redis.php';
include 'Router.php';
include 'controllers/ApplicationController.php';
include 'controllers/RedisController.php';
include 'controllers/iRedisType.php';
include 'bootstrap.php';
// http://blog.sosedoff.com/2009/07/04/simpe-php-url-routing-controller/
$r = new Router();
// create router instance
$r->map('/search', array('controller' => 'search', 'action' => 'index'));
$r->map('/', array('controller' => 'home'));
$r->default_routes();
$r->execute();
$class_name = $r->controller_name . 'Controller';
$path_to_controller = 'controllers/' . $class_name . '.php';
if (is_file($path_to_controller)) {
    require_once $path_to_controller;
} else {
    echo '<div class="error">Controller not found!</div>';
    exit;
}
$dispatch = new $class_name();
if (!method_exists($dispatch, $r->action)) {
    echo '<div class="error">Action <b>' . $r->action . '</b> not specified in <b>' . $r->controller_name . 'Controller</b></div>';
    exit;
} else {
    call_user_func_array(array($dispatch, "setParams"), array($r->params));
    call_user_func(array($dispatch, $r->action));
开发者ID:TitanInfrastructure,项目名称:RedisAdmin,代码行数:31,代码来源:index.php


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