Download the PHP package improwised/api-helper without Composer
On this page you can find all versions of the php package improwised/api-helper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download improwised/api-helper
More information about improwised/api-helper
Files in improwised/api-helper
Package api-helper
Short Description Laravel package to help consume REST and XML APIs with little effort.
License MIT
Informations about the package api-helper
Api Helper Package
A package to consume api smoothly
Explore the docs »
View Package
·
Report Bug
·
Request Feature
Table of Contents
- Getting Started
- Installation
- Configuration
- Usage
- Methods
- Response
Getting Started
This package is useful to consume API's, here is the instruction for installation and usage.
Installation
-
To install this package using Packagist
-
On the root of your project run following command
composer require improwised/api-helper
- This command will install package with dependency
Configuration
-
To use this apihelper need to export config file to do so run the following command in your terminal to publish config file to config folder.
php artisan vendor:publish --provider="Improwised\ApiHelper\ApiHelperServiceProvider"
- This will publish config file naming api_helper.php into config folder.
Prometheus Configuration
-
Prometheus is dependent on your app so you need to provide prometheus configuration and also use below packages on your app.
-
If you want to use prometheus then you should turn it on from config api_helper
- You can configure labels of prometheus inside
prometheus.labels
as per your need. histogram_bucket
you can set inside prometheus config as array.
Usage
-
To use this package you need to add following class where you want to use this package.
use Improwised\ApiHelper\ApiBuilder;
Methods
addHeaders($headers)
-
This method is use to add headers.
-
It accept name and value as parameter, Here you can set only one header at a time.
$headers['Accept'] = "application/json"; $headers['Content-Type'] = "application/json"; app(ApiBuilder::class)->addHeaders($headers);
- We will get response in form of object of ApiBuilder.
api($connection)
-
This method is use to set api that we are going to use from api_helper.php , there is httpbin and mokbin is define so you have to pass the name that you want to use.
-
You can also define your own api end point at api_helper.php in config file.
app(ApiBuilder::class)->api('httpbin')->method_to_call();
-
The snippet indicates how you can connect particular api and access their method.
-
method_to_call() is the function that you have specified inside api_helper connection array.
- This will return object of ApiResponse.
Response
- Here you will get object in response, In each response you will get success either true or false
- You will also get status code for more information about response please check below doc.
- http://docs.guzzlephp.org/en/latest/psr7.html#responses
All versions of api-helper with dependencies
php Version >=7.0.0
spatie/array-to-xml Version ^2.8
adbario/php-dot-notation Version ^2.2.0