本文整理汇总了PHP中Routes::Set方法的典型用法代码示例。如果您正苦于以下问题:PHP Routes::Set方法的具体用法?PHP Routes::Set怎么用?PHP Routes::Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Routes
的用法示例。
在下文中一共展示了Routes::Set方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CRUD
/**
* Function to create default routes CRUD
*
* @static
* @access public
* @param string $sRouteName
* @param string $sController
* @return void
*/
public static function CRUD($sRouteName, $sController)
{
if (method_exists($sController, "Index")) {
Routes::Set($sRouteName, "GET", $sController . "::Index");
}
if (method_exists($sController, "CRUDInsert")) {
Routes::Set($sRouteName, "POST", array($sController . "::CRUDInsert", new $sController()));
}
if (method_exists($sController, "CRUDEdit")) {
Routes::Set($sRouteName . "/{id}", "GET", array($sController . "::CRUDEdit", new $sController()));
}
if (method_exists($sController, "CRUDUpdate")) {
Routes::Set($sRouteName . "/{id}", "PUT", array($sController . "::CRUDUpdate", new $sController()));
}
if (method_exists($sController, "CRUDDestroy")) {
Routes::Set($sRouteName . "/{id}", "DELETE", array($sController . "::CRUDDestroy", new $sController()));
}
}
示例2:
<?php
/**
* Routes of Hello World
*
* @package MagicPHP Hello World
* @author André Ferreira <andrehrf@gmail.com>
* @link https://github.com/magicphp/magicphp MagicPHP(tm)
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
Routes::SetOverloadFrontend(true);
Routes::Set("", "GET", "App\\Helloworld\\Controllers\\Helloworld::Index");
Routes::SetDynamicRoute(function () {
Output::SendHTTPCode(404);
});