本文整理汇总了PHP中Routes::getRoutes方法的典型用法代码示例。如果您正苦于以下问题:PHP Routes::getRoutes方法的具体用法?PHP Routes::getRoutes怎么用?PHP Routes::getRoutes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Routes
的用法示例。
在下文中一共展示了Routes::getRoutes方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeCommand
/**
* Execute la commande d'affichage des routes de l'application
* @return string
*/
public function executeCommand()
{
// récupération des routes de l'application
require_once ROOT_DIR . '/app/routes.php';
$cadrecell = '+' . str_repeat("-", $this->lencell) . '+' . str_repeat("-", $this->lencellmethod) . '+' . str_repeat("-", $this->lencellalias) . '+' . str_repeat("-", $this->lencell) . '+' . "\n";
echo $cadrecell;
echo '| URL ' . str_repeat(" ", $this->lencell - 5) . '| METHOD ' . str_repeat(" ", $this->lencellmethod - 8) . '| ALIAS ' . str_repeat(" ", $this->lencellalias - 7) . '| CALL ' . str_repeat(" ", $this->lencell - 6) . '|' . "\n";
echo $cadrecell;
foreach (\Routes::getRoutes() as $method => $routes) {
foreach ($routes as $route) {
echo '| ' . $route->getPath() . str_repeat(' ', $this->lencell - strlen($route->getPath()) - 1);
echo '| ' . $method . str_repeat(' ', $this->lencellmethod - strlen($method) - 1);
echo '| ' . $route->getAlias() . str_repeat(' ', $this->lencellalias - strlen($route->getAlias()) - 1);
echo '| ' . $route->getCallable() . str_repeat(' ', $this->lencell - strlen($route->getCallable()) - 1) . '|' . "\n";
}
}
echo $cadrecell;
exit;
}
示例2: switch
switch ($_SERVER['REQUEST_METHOD']) {
case 'POST':
$request = 'post:' . $request;
break;
case 'PUT':
$request = 'put:' . $request;
parse_str(file_get_contents('php://input'), $_REQUEST);
break;
case 'DELETE':
$request = 'delete:' . $request;
break;
default:
$request = 'get:' . $request;
break;
}
try {
require '../../routes.php';
$routes = Routes::getRoutes();
foreach ($routes as $route) {
if (preg_match('/^' . $route[0] . '$/', $request, $matches)) {
$result = call_user_func($route[1], $matches);
break;
}
}
header('Content-Type: application/json');
echo json_encode($result);
} catch (Exception $e) {
header('HTTP/1.1 403 Forbidden');
header('Content-Type: application/json');
echo json_encode(['message' => $e->getMessage()]);
}
示例3: str_replace
<?php
//make use of absolute path when service launth.
require_once "routes.php";
require_once "DjentController.php";
$url = str_replace("http://got-djent.com/", "", $_GET["url"]);
$routes = Routes::getRoutes(str_replace("http://got-djent.com/", "", $_GET["url"]));
$routes["controller"]::$routes["action"]($routes["id"]);
示例4: getRoutes
/**
* Fonction de test ( development )
* @return [type] [description]
*/
function getRoutes()
{
require __DIR__ . '/tests/routes.php';
$test = Routes::getRoutes();
var_dump($test);
}
示例5: loadRoutes
function loadRoutes()
{
return Routes::getRoutes();
}