Download the PHP package piggly/php-http without Composer

On this page you can find all versions of the php package piggly/php-http. 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 php-http

Packing to Request/Response for APIs

This library was developed to meet Piggly team requirements. It may not work to you, but work so well to us, expanding the flexibility of our HTTP management.

Today, there are a lot of ways to manipulate requests and responses at PHP. The most common pattern is following the PSR-7 interfaces (see here), which makes easy to manipulate HTTP protocol data.

But, nothing is perfect. Some frameworks, smart customizations and even handcraft artists can create your own patterns for handle HTTP requests and responses. It makes hard to packing some data and create libraries without forcing standards.

For example, Laravel uses Illuminate\Http packages which has no PSR-7 implementation. So, when you are creating an external global library which requires PSR-7 implementation, well... Laravel artists has to do some fixes to everythings work well an so on.

We know, you can get the PSR-7 from Laravel Requests\Response, but then you have to go back if you want to use native Laravel HTTP resources and functions. Why so complicated? And, this is main reason to our library exists. To solve it. By implementing smart abstract classes to request and response which can handle any type request and response objects, still access the original request/response and use the most common methods.

First of all, this library was thought to APIs. An API has some behaviours attached to requests and responses. In general, from API requests we get body parameters, query string parameters and headers.

We also want to packing content data for responses as smart objects. Or even, transform request parameters to smart objects to better handle expected values and validation. And better, we can handle exceptions by automatically converting it to a response with no headache.

To achieve it, at responses we include an standard payload with status and messages, as:

The response payload, however, will have two different behavior. When, response code is equal to BaseResponse::SUCCESS_CODE, then payload will be the response. If not, then payload will be added to body key at response. See below:

Responses incluing code as BaseResponse::SUCCESS_CODE:

Any other responses codes:

From now, by usign this package, our libraries are much more flexibles. It doesn't care if you're using the pure PHP variables, PSR-7 interfaces or event Illuminate\Http. Just packing whatever Request and Response objects you are using to a basic BaseRequest and BaseResponse objects without losing your original objects.

See below how everything works.

BaseRequest object

The BaseRequest object defines the HTTP request for application. It's an abstract class which makes our original request object acessible and do some universal implementations:

And has some functions:

BaseResponse object

The BaseResponse object defines the HTTP response for application. It's an abstract class which makes our original response object acessible and do one universal implementation:

And has some functions:

PayloadRequest and PayloadResponse

Both manage payloads for Requests and Responses. They are not required. However, BaseResponse will require any PayloadInterface to dealing with payloads.

ResponseException handler

Create an exception that can be handled to a response. It will make easy just throw an exception to client which can be converted to a response object. And has some functions:

There is also some default exceptions models to throw:

method code http_code message
ResponseException::invalidParameter 5 422 Invalid parameters found => the request parameters are invalid or malformed.
ResponseException::invalidQueryParameter 5 422 Invalid parameters found => the request query parameters are invalid or malformed.
ResponseException::invalidRequest 15 400 The request data is invalid and has failed.
ResponseException::serverError 20 500 Request has failed.

Changelog

See the CHANGELOG file for information about all code changes.

Testing the code

This library uses the PHPUnit. We carry out tests of all the main classes of this application.

Contributions

See the CONTRIBUTING file for information before submitting your contribution.

Credits

Support the project

Piggly Studio is an agency located in Rio de Janeiro, Brazil. If you like this library and want to support this job, be free to donate any value to BTC wallet 3DNssbspq7dURaVQH6yBoYwW3PhsNs8dnK ❤.

License

MIT License (MIT). See LICENSE.


All versions of php-http with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2 || ^8.0
piggly/php-payload Version ^1.0.4
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 piggly/php-http contains the following files

Loading the files please wait ....