Update README.md
This commit is contained in:
parent
206b7d5c2a
commit
6c58c1446b
18
README.md
18
README.md
|
|
@ -1,7 +1,7 @@
|
||||||
WellRESTed
|
WellRESTed
|
||||||
==========
|
==========
|
||||||
|
|
||||||
WellRESted provides classes to help you create RESTful APIs and work with HTTP requests and responses.
|
WellRESTed provides classes to help you create RESTful APIs and work with HTTP requests and responses.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -17,7 +17,7 @@ Requirements
|
||||||
Install
|
Install
|
||||||
-------
|
-------
|
||||||
|
|
||||||
Add an entry for "pjdietz/wellrested" in your composer.json file's **require** property. If you are not already using Composer, create a file in your project called **composer.json** with the following content:
|
Add an entry for "pjdietz/wellrested" to your composer.json file's **require** property. If you are not already using Composer, create a file in your project called **composer.json** with the following content:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
|
|
@ -34,13 +34,16 @@ $ curl -s https://getcomposer.org/installer | php
|
||||||
$ php composer.phar install
|
$ php composer.phar install
|
||||||
```
|
```
|
||||||
|
|
||||||
|
You can now use WellRESTed by including the autoload.php file generated by Composer. (vendor/autoload.php)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Examples
|
Examples
|
||||||
--------
|
--------
|
||||||
|
|
||||||
### Responses
|
### Responses
|
||||||
|
|
||||||
Build a response and use it to send output.
|
Use a Response instance to build a response and send output. The Request class makes it easy to set the status code, add headers, and set the response body.
|
||||||
|
|
||||||
```php
|
```php
|
||||||
$resp = new \pjdietz\WellRESTed\Response();
|
$resp = new \pjdietz\WellRESTed\Response();
|
||||||
|
|
@ -53,7 +56,9 @@ exit;
|
||||||
|
|
||||||
### Requests
|
### Requests
|
||||||
|
|
||||||
You can access a Request singleton instance that represents the request sent to the current script.
|
Use the Request class read information about the request sent to the server. You can ready the headers, method, and message body.
|
||||||
|
|
||||||
|
Request provides a singlton instance representing the request sent to the current script.
|
||||||
|
|
||||||
```php
|
```php
|
||||||
$rqst = \pjdietz\WellRESTed\Request::getRequest();
|
$rqst = \pjdietz\WellRESTed\Request::getRequest();
|
||||||
|
|
@ -64,7 +69,7 @@ if ($rqst->method === 'PUT') {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
The Request class can also make a request to another server and provide the response as a Respones object. (This feature requires [PHP's cURL](http://php.net/manual/en/book.curl.php).)
|
The Request class can also make a request to another server and provide the response as a Respones object. (This feature requires [PHP cURL](http://php.net/manual/en/book.curl.php).)
|
||||||
|
|
||||||
```php
|
```php
|
||||||
// Prepare a request.
|
// Prepare a request.
|
||||||
|
|
@ -120,5 +125,4 @@ class MyRouter extends \pjdietz\WellRESTed\Router
|
||||||
More explamples
|
More explamples
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
For more examples, see the project [pjdietz/wellRrested-samples](https://github.com/pjdietz/wellrested-samples).
|
For more examples, see the project [pjdietz/wellrested-samples](https://github.com/pjdietz/wellrested-samples).
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue