Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Sep 11, 2017
1 parent e3ecd33 commit ae1196f
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 31 deletions.
32 changes: 31 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,31 @@
# php http lib
# php http message

some useful http message library(psr7 implement) of the php

## project

- **github** https://github.com/inhere/php-console.git
- **git@osc** https://git.oschina.net/inhere/php-console.git

## install

- by composer

edit `composer.json`,at `require` add

```
"inhere/http": "dev-master",
```

run: `composer update`

- Direct fetch

```
git clone https://git.oschina.net/inhere/php-http.git // git@osc
git clone https://github.com/inhere/php-http.git // github
```

## license

MIT
38 changes: 13 additions & 25 deletions src/Extra/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
* Time: 14:05
*/

namespace inhere\http;
namespace Inhere\Http\Extra;

use Inhere\Http\UploadedFile;
use Inhere\Http\Uri;
use inhere\validate\FilterList;
use inhere\library\DataType;

/**
* Class Request
* @package inhere\library\http
* @package Inhere\Http\Extra
*
* @method string getRaw($name, $default = null) Get raw data
* @method integer getInt($name, $default = null) Get a signed integer.
Expand All @@ -27,9 +29,9 @@
* @method string getEmail($name, $default = null)
* @method string getUrl($name, $default = null) Get URL
*
* @property \Slim\Http\Uri $uri;
* @property Uri $uri;
*/
class Request extends \Slim\Http\Request
class Request extends \Inhere\Http\Request
{
/**
* return raw data
Expand Down Expand Up @@ -80,17 +82,9 @@ public function all()
return $this->getParams();
}

/**
* @return array|null
*/
public function post()
{
return $this->getParsedBody();
}

/**
* @param $name
* @return \Slim\Http\UploadedFile
* @return UploadedFile
*/
public function getUploadedFile($name)
{
Expand All @@ -103,8 +97,12 @@ public function getUploadedFile($name)
* @param string $filter
* @return mixed
*/
public function get($name, $default = null, $filter = 'raw')
public function get($name = null, $default = null, $filter = 'raw')
{
if ($name === null) {
return $this->getQueryParams();
}

$value = $this->getParams()[$name] ?? $default;

return $this->filtering($value, $filter);
Expand Down Expand Up @@ -155,16 +153,6 @@ public function getRequestUri()
return $this->getRequestTarget();
}

/**
* Is this an XHR request?
*
* @return bool
*/
public function isAjax()
{
return $this->isXhr();
}

/**
* Is this an pjax request?
* pjax = pushState + ajax
Expand All @@ -187,7 +175,7 @@ public function getPjaxContainer()
* @param string $default
* @return string
*/
public function getReferer($default = '/')
public function getReferrer($default = '/')
{
return $this->getHeaderLine('REFERER') ?: $default;
}
Expand Down
9 changes: 4 additions & 5 deletions src/Extra/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
* Time: 14:06
*/

namespace inhere\http;
namespace Inhere\Http\Extra;

/**
* Class Response
* @package inhere\library\http
* @package Inhere\Http\Extra
*/
class Response extends \Slim\Http\Response
class Response extends \Inhere\Http\Response
{
/**
* @param mixed $data
Expand All @@ -26,9 +26,8 @@ public function withRawJson($data, $status = 200, $encodingOptions = 0)
}

/**
* @param mixed $data
* @param string $fallbackUrl
* @param int $status
* @param int $encodingOptions
* @return static
*/
public function withGoBack($fallbackUrl = '/', $status = 301)
Expand Down

0 comments on commit ae1196f

Please sign in to comment.