Download the PHP package restful-template/response-template without Composer
On this page you can find all versions of the php package restful-template/response-template. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download restful-template/response-template
More information about restful-template/response-template
Files in restful-template/response-template
Package response-template
Short Description A response interface builder for REST API
License GPL-3.0-or-later
Homepage https://github.com/enriquerene/response-template.git
Informations about the package response-template
Response Template
A response interface builder for REST API.
Table of Contents
- Installation
- Usage
- Simples Case
- Data in Response
- Links Setup
- Plan
- Support
- Contribute
Installation
There are some installation ways. You can choose the best way for you.
Composer (recommended)
This way requires Composer:
Git
Clone the repo into your project:
Zip
Dowload the package and uncpack it into your project: Dowload ZIP
Usage
ResponseTemplate requires an valid HTTP Status Code. Refer to section 10 of RFC 2616.
Simplest Case
The simplest case is to instantiate the class ResponseTemplate with HTTP Status Code "200 Ok." and call method build:
Data in Response
It's possible insert data to response at the build moment:
Links Setup
You can make use of setLink method to setup a link to response:
It's possible insert a third argument into setLink method to define "method" property of link. If you want work with a POST route, for example, you probrably would like to use $rest = $rest->setLink( "create", "/products", "POST" );.
Plan
This project aims to be up to date with standards. Future version may be aligned to RFC 7231. Some implementation in the roadmap:
Setting custom link key
- If just the query string starting with
?is given, the same basename and path will be retrieved as inself url. - If just the path is given, the same basename will be retrieved as in
self url. - If a basename including
.is given, the same protocol will be retrieved as inself url. - Given full path including http/https protocol will be placed as it is into custom key url property.
Support
If you need some help you can open an issue.
Contribute
Do a pull request or send email to Support.