PHP模块库实现之路由(router)
<?php
namespace RouteModule;
include_once __DIR__ . "/../Receive/Receive.php";
include_once __DIR__ . "/../Response/Response.php";
include_once __DIR__ . "/../Log/Log.php";
class RouteModel
{
public $path;
public $path_match;
public $global_args;
public $args = array();
public $log = false;
public $log_path = __DIR__ . "\\logs";
public $desc;
public $receive_data;
public $receive_params = array();
public $receive_method = "GET";
public $request_data;
public $request_method = "GET";
public $hooks = array();
public $response;
public $params = array();
}
class RouteModule extends RouteModel
{
public function __construct($options = array())
{
$this->path = isset($options["path"]) ? $options["path"] : $this->path;
$this->args = isset($options["args"]) ? $options["args"] : $this->args;
$this->global_args = isset($options["global_args"]) ? $options["global_args"] : $this->global_args;
$this->log = isset($options["log"]) ? $options["log"] : $this->log;
$this->log_path = isset($options["log_path"]) ? $options["log_path"] : $this->log_path;
$this->desc = isset($options["desc"]) ? $options["desc"] : $this->desc;
$this->receive_method = isset($options["receive_method"]) ? $options["receive_method"] : $this->receive_method;
$this->receive_params = isset($options["receive_params"]) ? $options["receive_params"] : $this->receive_params