Download the PHP package gajosu/laravel-http-service without Composer
On this page you can find all versions of the php package gajosu/laravel-http-service. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gajosu/laravel-http-service
More information about gajosu/laravel-http-service
Files in gajosu/laravel-http-service
Package laravel-http-service
Short Description This is my package laravel-http-service
License MIT
Homepage https://github.com/gajosu/laravel-http-service
Informations about the package laravel-http-service
Laravel Http Client Service
Do you make a lot of http requests to microservices or external apis in your laravel projects?
There are many packages to do this, but I haven't found one that is easy to test and that offers caching functionality.
This package allows you to create your own services, make requests and test them easily.
Installation
You can install the package via composer:
Usage
You can start using it easily, simply by calling the request()
method of the facade HttpService
Make your own service
As explained in the example above, you can start using the package with its base classes, but the purpose of this package is to make it easy to create your own services.
You can make your own service by extending the Gajosu\LaravelHttpClient\HttpService
class.
Rewrite the getBuilder()
method and set Base Uri, headers, queries, etc.
In the next example we will make a service that sends requests to http://myservice.com
base url and set a access token in the headers.
The next step is to create a facade for the service extending the Gajosu\LaravelHttpClient\Facades\HttpService
class.
Now you can use the service in your application.
Caching Responses
The package also allows you to cache the responses.
Faking Responses
For example, to instruct the package to return a fake response with code 200 and empty body for all requests, you can use the fake()
method.
Specifying responses
You can also specify the responses code, headers and body passing an array to the shouldReceiveResponses
method.
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Gabriel Gonzalez
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-http-service with dependencies
guzzlehttp/guzzle Version ^7.0
illuminate/contracts Version ^9.0|^8.0
spatie/laravel-package-tools Version ^1.9.2