Download the PHP package ftd-educacao/default-api-response without Composer

On this page you can find all versions of the php package ftd-educacao/default-api-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 default-api-response

FTD Default API Response

Welcome to FTD Default API Response!


About

This package was created to extend the Laravel Framework response system, and elevate him to the standard described on the {json:api} website[^jsonapi].

The answers besides creating a more friendly and readable formatting also contemplate the control of the Headers according to the last code.


Installation

Use composer do install our package:

And call the provider inside your Laravel /config/app.php file:

Now it's done and we're ready to go!


How to use

FTD API Response give us 5 new methods:

  1. success
  2. paginate
  3. error
  4. custom
  5. defaultStatusCode

Every method has a particular way to use, but always easy.

The success method

This method will throw a header status code 200 and put your content inside a data wrapper:

Example:

Result:

Example:

Result:

The paginate method

This method will throw a header status code 200 and put your content inside a data wrapper, and create another wrapper called meta, for the pagination properties:

Example:

Result:

The error method

This method will throw a header status code 400 and put your content inside a errors wrapper:

Example:

Result:

Advanced use for the success, paginate and error methods

If you need change the default status code of this methods, you can give a second parameter, like:

The custom method

This method is used for who need more control of the entire response:

Example:

Result: In your header you will see the:

or

Depends on which browser you are using.

And, finally, the response body will receive the contents, but without the default data wrapper:

If you need to force download of a PDF file, for example, this method is the right way to do it.

The defaultStatusCode method

This method will throw a header status code and depends on which code, put default message content inside a data or errors wrapper:

Example:

Result:

The code list for defaultStatusCode method

Code Reference
102 'Processing',
200 'OK',
201 'Created',
202 'Accepted',
203 'Non-authoritative Information',
204 '',//No Content
206 'Partial Content',
207 'Multi-Status',
302 'Found',
304 'Not Modified',
400 'Bad Request',
401 'Unauthorized',
402 'Payment Required',
403 'Forbidden',
404 'Not Found',
405 'Method Not Allowed',
406 'Not Acceptable',
409 'Conflict',
413 'Payload Too Large',
415 'Unsupported Media Type',
416 'Requested Range Not Satisfiable',
422 'Unprocessable Entity',
423 'Locked',
424 'Failed Dependency',
500 'Internal Server Error',
501 'Not Implemented',
503 'Service Unavailable'

If you need more information about status code, the HTTP Status Codes website[^statuscodes] may help you.

[^jsonapi]: {json:api} A specification for building apis in json.

[^statuscodes]: httpstatuses.com is an easy to reference database of HTTP Status Codes with their definitions and helpful code references all in one place.


All versions of default-api-response with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
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 ftd-educacao/default-api-response contains the following files

Loading the files please wait ....