Download the PHP package johnpbloch/fluent-http-api without Composer

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

Fluent HTTP API Wrapper

Use this library to quickly build wrappers for HTTP APIs

Installation

Add this to your PHP project with composer:

Usage

Customize Configuration

The following is only necessary if you are building a library meant for distribution!

If you are incorporating this in a codebase meant to be used as a library (i.e. as a dependency in other projects), you should create your own extensions of the \JohnPBloch\FluentApi\Config and \JohnPBloch\FluentApi\Endpoint classes and ensure that initializing the configuration object for your library stores that configuration in your custom base endpoint:

Authorization

This package provides a number of methods of adding authorization to requests. NOTE: This library does not handle authentication, it assumes you already have credentials available to use. The following methods of authorization are available:

Basic Auth
Digest Auth
NTLM Auth
Bearer Token Auth

Only include the token, not the Bearer prefix.

Header Key/Value Auth
Query Key/Value Auth
Cookie-based Auth

Initialize Configuration

Before using this library, you will have to initialize the configuration object. If you extended the Config object for packaging in a library, use that config object instead of \JohnPBloch\FluentApi\Config.

Make Requests

Use the method() method to set the HTTP request method (e.g. GET, POST, etc.)

Use the path() method to set the path relative to the configured base uri.

The send() method will send the request and return a PSR-7 compatible Guzzle response.

Additionally, the Endpoint class extends the Laravel Fluent class and can add generic data to the request using fluent methods. By default, GET, POST, and PUT will automatically add fluent attributes to the request. GET data will be added to the query variables; POST and PUT requests will set fluent attributes to body data as a application/x-www-form-urlencoded request. If you need to further adjust the request, you will need to extend Endpoint to further adjust the config data before sending.

For example, a simple GET request:

Or a Post Request:

Overriding Configuration Settings

If there is a specific configuration option you need to override, you can extend the Endpoint class and set public or protected methods to override values. There are two types of override methods: setRequestConfig* and mergeRequestConfig*. For each one, the remaining text after Config will determine the configuration key that will be set. The text will be snake-cased before using. So for example, a method named setRequestConfigFormParams() will set the return value to form_params in Guzzle options.

setRequestConfig* methods will get the current Guzzle option as the only parameter and whatever the method returns will get set to the Guzzle options.

mergeRequestConfig* methods will merge the return value into the existing (possibly empty) value in the Guzzle options. There is no input for these methods.

Before sending the Guzzle request, the Endpoint will call beforeSend($options). beforeSend can return either an options array or a \Psr\Http\Message\ResponseInterface object. If it returns an options array, the request will send as expected. If it returns a response object, it will be returned as-is without sending the request or running the afterSend method.

After sending the Guzzle request, the response object will call afterSend() with the response. afterSend() must return a response as well, and that response will be returned by send().

License

Licensed under MIT license.


All versions of fluent-http-api with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0.0
illuminate/support Version ^9.0 || ^10.0
guzzlehttp/guzzle Version ^7.7
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 johnpbloch/fluent-http-api contains the following files

Loading the files please wait ....