Download the PHP package cubesystems/api-client without Composer

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

API Client

This package defines contracts and provides abstract partial implementations of those contracts. It is meant to be used as a base building block for your own highly modular and customisable implementation of API consumption. Feel free to use as little or as much of it as you need.

Installation

You can install the package via composer:

Configuration

To use Laravel Debugbar integration, enable it within debugbar.php config file:

Creating custom API client implementation

First of all, let's define some vocabulary.

SOAP

Methods, services and endpoints

REST

Methods, services and endpoints

After this, we can look at the relations between all interfaces:

Relationship between main interfaces

Define an endpoint

For this, we need to implement CubeSystems\ApiClient\Client\Contracts\Endpoint contract which can be done by extending CubeSystems\ApiClient\Client\AbstractRestEndpoint or CubeSystems\ApiClient\Client\AbstractSoapEndpoint class:

Define a service accessible within an endpoint

For this, we need to implement CubeSystems\ApiClient\Client\Contracts\Service contract which can be done by extending CubeSystems\ApiClient\Client\AbstractRestService or CubeSystems\ApiClient\Client\AbstractSoapService class:

Create a request payload class

This can be done by implementing CubeSystems\ApiClient\Client\Contracts\Payload contract directly or by extending CubeSystems\ApiClient\Client\Payloads\AbstractPayload class:

Create a response class

This can be done by implementing CubeSystems\ApiClient\Client\Contracts\Response contract directly or by extending CubeSystems\ApiClient\Client\Responses\AbstractResponse class:

Create a method for a service

CubeSystems\ApiClient\Client\Contracts\Method is implemented by CubeSystems\ApiClient\Client\Methods\AbstractRestMethod and CubeSystems\ApiClient\Client\Methods\AbstractSoapMethod classes.

Calling an API

After all that, you can make calls like this:

Or take advantage of dependency injection done by Laravel.

Extend CubeSystems\ApiClient\ApiClientServiceProvider class and register your bindings:

Now the same thing can be done more concisely:

Take a look at tests for more detailed examples.

Caching

AbstractMethod class includes a caching mechanism. Just pass desired cache strategy to the constructor. There are 3 strategies available:

You can also create your own strategy by implementing CubeSystems\ApiClient\Client\Contracts\CacheStrategy contract.

CubeSystems\ApiClient\Client\Contracts\Payload::getCacheKey() method is used to decide if there are valid cache entries for a given payload. If there are, the response is retrieved from cache. Otherwise, the remote API is called.

Hierarchical caching

If payload returns true from isUsingCacheHierarchy method, then corresponding call will be made part of the cache hierarchy. This allows to invalidate all cache entries for given hierarchy at once by calling AbstractMethod's removeHierarchyFromCache method.

For this to work, CubeSystems\ApiClient\Client\Contracts\Payload::getCacheHierarchyKey method must be implemented according to your needs.

Moreover, AbstractPayload now accepts optional CachePrefix parameter which can be used to differentiate between cache hierarchies for the same type of method and payload. Typical use case would be to distinguish between different users' cache hierarchies.

There is more

Events

CubeSystems\ApiClient\Client\Methods\AbstractMethod class fires the following events:

You can listen to those and do some additional stuff like logging.

Laravel Debugbar integration

If debugbar.collectors.api configuration option is set to true as described above, all API calls (and cache retrievals) will be visible within Laravel Debugbar:

Debugbar integration

Testing

This package uses Pest testing framework. You can run tests with

Changelog

Please see CHANGELOG for more information on what has changed recently.


All versions of api-client with dependencies

PHP Build Version
Package Version
Requires php Version 8.0.*
ext-bcmath Version *
ext-intl Version *
ext-soap Version *
ext-xsl Version *
codedredd/laravel-soap Version ^3.0
illuminate/contracts Version ^9.0
nesbot/carbon Version ^2.66
spatie/laravel-package-tools Version ^1.14.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 cubesystems/api-client contains the following files

Loading the files please wait ....