Download the PHP package kielabokkie/laravel-guzzle-api-service without Composer

On this page you can find all versions of the php package kielabokkie/laravel-guzzle-api-service. 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?

All versions of laravel-guzzle-api-service with dependencies

Informations about the package laravel-guzzle-api-service

Laravel Guzzle API Service

Note: This package is still being developed and is not production ready. Use at your own risk!

Installation

Install the package via composer:

composer require kielabokkie/laravel-guzzle-api-service

Package configuration

Publish the config file by running the following command:

This is the contents of the file that will be published at config/api-service.php:

Setup

To make use of the base API Client class you'll need to add the required $baseUrl to set the base URL of your API. You'll also have to call the $this->setClient(); function in the constructor of your service class.

To make it easy to get started you can use the following command to scaffold your API Service class:

This will create a class called HttpBinService.php in the app/Support/Services folder. All you have to do is set your $baseUrl and you are good to go.

Note: If you would like your classes to be placed somewhere else you can overwrite the namespace variable in the api-service.php config file.

Usage

Get request

Now to execute a GET request you can simply do the following:

This is pretty basic stuff and the same as you would normally do a GET request with Guzzle.

Adding default headers

APIs often require you to add a specific header to every request, for example for authorisation purposes. Instead of having to pass that as an option with every request you can add the following function at the top of your service class:

Adding default query parameters

You can add default query parameters to every request automatically in a similar way:

This will automatically append the token as a get parameter like so: https://httpbin.org/get?token=your-token.


Version
Requires guzzlehttp/guzzle Version ^6.3
rtheunissen/guzzle-log-middleware Version ^0.4.2

The package kielabokkie/laravel-guzzle-api-service contains the following files

Loading the files please wait ....