Download the PHP package vertilia/response without Composer

On this page you can find all versions of the php package vertilia/response. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package response

response

Simple library to abstract response data for several popular formats and provide output schema validation capabilities based on php-filter extension.

The use of ValidArray mechanism guarantees the output will match the predefined response schema.

Use case

Your controller is an HttpResponse object with predefined filters. Filters configuration corresponds to the response schema for the particular route and is defined in leaf data of routes file under response element.

During pre-rendering phase controller sets corresponding elements as defined in response. At this moment validation mechanism evaluates values and sanitizes them if necessary to correspond to the filtering rules.

Items not present in filters list are discarded. Invalid values are set to false. Correct values are set as is. Items present in validation schema but not set take null value. Rules may be modified using php-filter flags constants and ValidArray enhancements, including default values for all filters (not only FILTER_VALIDATE_* filters).

In the following example request controller UserGetEmail is defined in route file as a handler for GET /api/users/{id}/email route. On creation, it receives validation filters and an HttpRequest object with request information. When render() method is called on this controller, it renders an HTTP response as JSON text with corresponding headers, this work is done by JsonResponse. What is handled by the controller itself is located in preRender() method. It populates controller elements id (from request) and email (from User object). These pre-validated elements will correspond the initial response schema and will be output in a JSON format (like {"id":42,"email":"[email protected]"}).

Since JsonResponse object is generated per operation, it includes exactly the filters needed for this specific operation. Populating and returning this response object guarantees that the rendered version will correspond to response schema.

Extending basic use case

Implementing preliminary check of required request parameters is what we leave to the user land since it is normally coupled with error messaging. If interested in implementing localised text messages, have a look at vertilia/text package on GitHub.

Correct instantiation and more use cases for HttpRequest and HttpRouter services may be found in corresponding packages, have a look at vertilia/request and vertilia/router pages.

A more complex controller implementation, handling request validation errors and multiple responses per route as defined in OpenAPI specification may be found in vertilia/controller package.


All versions of response with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
ext-json Version *
vertilia/valid-array Version ^1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package vertilia/response contains the following files

Loading the files please wait ....