Download the PHP package tobento/service-responser without Composer
On this page you can find all versions of the php package tobento/service-responser. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tobento/service-responser
More information about tobento/service-responser
Files in tobento/service-responser
Package service-responser
Short Description Providing PSR-7 response wrapper classes with simplified methods.
License MIT
Homepage https://www.tobento.ch
Informations about the package service-responser
Responser Service
Providing PSR-7 response wrapper classes with simplified methods.
Table of Contents
- Getting started
- Requirements
- Highlights
- Documentation
- Responser
- Create Responser
- Renderer
- Storage
- Html Response
- Json Response
- Render View Response
- Any Content Response
- Redirect Response
- Messages
- Flash Messages
- Flash Input Data
- Additional Responser Methods
- Create Responser
- File Responser
- Create File Responser
- Render File Response
- Download File Response
- Additional File Responser Methods
- Response Info
- Middleware
- Responser Middleware
- Merge Input Middleware
- Responser
- Credits
Getting started
Add the latest version of the requester service project running this command.
Requirements
- PHP 8.0 or greater
Highlights
- Framework-agnostic, will work with any project
- Decoupled design
- Flash messages
- Flash input data
Documentation
Responser
Create Responser
Renderer
You may add a renderer if you want to Render View Responses.
Firstly, make sure you have the view service installed if you want to use the view renderer, otherwise you may implement your own renderer:
Check out the View Service to learn more about it in general.
Storage
You may add a storage if you want to flash messages and/or input data.
Firstly, make sure you have the session service installed if you want to use the session storage, otherwise you may implement your own storage:
Check out the Session Service to learn more about how to start session.
Html Response
Writes HTML into the body response and sets "text/html; charset=utf-8" content-type header.
Json Response
Writes JSON data into the body response and sets "application/json" content-type header.
Render View Response
Renders the specified view writing into the body response and sets "text/html; charset=utf-8" content-type header as default.
Check out Renderer to learn more about the renderer implementation.
Any Content Response
Writes data into the body response.
Redirect Response
Messages
You may add messages for the current and/or next request.
Check out the Message Service to learn more about it in general.
in views/shop/products.php
Flash Messages
You will need to provide a storage in order to flash messages.\ Check out Storage to learn more about the storage implementation.
On the redirected uri:
Flash Input Data
You will need to provide a storage in order to flash input data.\ Check out Storage to learn more about the storage implementation.
On the redirected uri:
Using middleware
You may check out the Merge Input Middleware to merge the input data with the request data.
Additional Responser Methods
create
You may create a response from the response factory:
streamFactory
You may get the stream factory:
file
You may get the file responser:
Check out File Responser to learn more about the file repsonser in general.
info
You may get the response info:
Check out Response Info to learn more about the response info in general.
File Responser
Create File Responser
Render File Response
Create response to render (display) the file on browser.
Parameters explanation
Parameter | Description |
---|---|
file | The file to render. |
name | Required if file is of type StreamInterface or resource, otherwise you may leave empty. |
contentType | If null, it gets determined automatically. |
Download File Response
Create response to download the file.
Parameters explanation
Parameter | Description |
---|---|
file | The file to download. |
name | Required if file is of type StreamInterface or resource, otherwise you may leave empty. |
contentType | If null, it gets determined automatically. |
Additional File Responser Methods
create
You may create a response from the response factory:
streamFactory
You may get the stream factory:
info
You may get the response info:
Check out Response Info to learn more about the response info in general.
Response Info
isInformational
If the response is informational, status codes 1xx.
isSuccessful
If the response is successfull, status codes 2xx.
isRedirection
If the response is a redirection, status codes 3xx.
isClientError
If the response is a client error, status codes 4xx.
isServerError
If the response is a server error, status codes 5xx.
isOk
If the response is ok, status code 200.
isForbidden
If the response is a forbidden error, status code 403.
isNotFound
If the response is a not found error, status code 404.
isCode
If the response is of the specified status code(s).
Middleware
Responser Middleware
Adds the responser to the request attributes.
Merge Input Middleware
Merges the responser input with the request input.
Credits
- Tobias Strub
- All Contributors
All versions of service-responser with dependencies
psr/http-message Version ^1.0
psr/http-factory Version ^1.0
psr/http-server-handler Version ^1.0
psr/http-server-middleware Version ^1.0
tobento/service-message Version ^1.0
tobento/service-support Version ^1.0
tobento/service-filesystem Version ^1.0