Skip to content

Commit

Permalink
添加getPathInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
boxunsoft committed Jun 24, 2020
1 parent 2315087 commit 72bbcf3
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/BagTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function query(): InputBag
*/
public function post(): ParameterBag
{
return $this->req->post;
return $this->req->request;
}

/**
Expand Down
65 changes: 65 additions & 0 deletions src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,36 @@ public function __construct()
$this->req = HttpFoundationRequest::createFromGlobals();
}

/**
* 带queryString
*
* @return void
*/
public function getRequestUri()
{
return $this->req->getRequestUri();
}

/**
* 整个URL
*
* @return string
*/
public function getUri()
{
return $this->req->getUri();
}

/**
* 不带queryString的path
*
* @return string
*/
public function getPathInfo()
{
return $this->req->getPathInfo();
}

/**
* 请求ID
*
Expand All @@ -65,21 +85,41 @@ public function getBody()
return $this->req->getContent();
}

/**
* HTTP协议名
*
* @return string
*/
public function getServerScheme()
{
return $this->req->getScheme();
}

/**
* 服务器主机
*
* @return string
*/
public function getServerHost()
{
return $this->req->getHost();
}

/**
* 服务器名
*
* @return string
*/
public function getServerName()
{
return $this->server()->get('SERVER_NAME', '');
}

/**
* 服务器端口
*
* @return void
*/
public function getServerPort()
{
return $this->req->getPort();
Expand All @@ -104,26 +144,51 @@ public function getServerIp()
return $this->serverIp;
}

/**
* 客户端IP
*
* @return string
*/
public function getClientIp()
{
return $this->req->getClientIp();
}

/**
* 客户端端口
*
* @return string
*/
public function getClientPort()
{
return $this->server()->get('REMOTE_PORT', '');
}

/**
* 客户端UA
*
* @return string
*/
public function userAgent()
{
return $this->header()->get('HTTP_USER_AGENT');
}

/**
* 来源地址
*
* @return string
*/
public function referer()
{
return $this->header()->get('HTTP_REFERER');
}

/**
* 是否是Ajax请求
*
* @return boolean
*/
public function isXmlHttpRequest()
{
return $this->req->isXmlHttpRequest();
Expand Down

0 comments on commit 72bbcf3

Please sign in to comment.