Download the PHP package rnr1721/le7-api-request without Composer

On this page you can find all versions of the php package rnr1721/le7-api-request. 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 le7-api-request

le7-api-request

API client for le7 PHP MVC framework or any PSR project This is an simple PSR API client implementation

API Request Utility

This project provides a simple utility for simple making HTTP requests to an API. It includes a factory class for creating instances of the API request utility.

It not have own PSR ClientInterface implementation, and you can use any own. For example: https://github.com/rnr1721/le7-http-client

What it can?

Requirements

Installation

  1. Install via composer:

Testing

Usage

In this example, I use Nyholm PSR library, but you can use any, Guzzle for example. Also, you will need the ClientInterface implementation. I use this implementation: https://github.com/rnr1721/le7-http-client

Headers

You can use global headers, and headers for each request. Headers for each request you can inject in request methods when you call it or by setHeader() & setHeaders() methods. Now, you will see how setup global headers, that will be added for all requests:

Also for one-time request headers:

Sending files with multipart/form-data

Client setup

If you are using my implementation of ClientInterface, https://github.com/rnr1721/le7-http-client you can setup some options of client:

JSON and form-data

You can create these content-types of requests:

By default is json, but you can switch to form-data:

Another way is set header. It turn needle mode automatically

Convertors

By default, you can convert recieved ResponseInterface to array or object like this:

Also, you can write own convertor. It must implement ResponseConvertorInterface:

As examples you can see ResponseArrayConverter and ResponseObjectConverter

Also, you can inject convertor when create ApiRequest instance:

Multiple HTTP clients

You can use different ClientInterface in different situations. Any client have own key. When you create instance of ApiRequest, ClientInterface that you inject have key 'default'. For some reasons you may need add ClientInterface instance. So, you can make this:

Uri prefixes

You can set the Uri prefix to add before all url in two way

When creating ApiRequest instance:

When you have already created instance

Container configuration

In this example I using these components, but you can use any others:

PSR Events

You can log requests or somehow else use event AfterApiRequestEvent:


All versions of le7-api-request with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
psr/http-client Version ^1.0
psr/http-factory Version ^1.0
psr/http-message Version ^2.0
psr/event-dispatcher Version ^1.0
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 rnr1721/le7-api-request contains the following files

Loading the files please wait ....