Download the PHP package retailcrm/api-client-php without Composer

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

Build Status Coverage Latest stable PHP from Packagist

RetailCRM API PHP client

This is the PHP RetailCRM API client. This library allows using of the actual API version.
You can find more info in the documentation.

Table of contents

Requirements

Installation

Follow those steps to install the library:

  1. Download and install Composer package manager.
  2. Install the library from the Packagist by executing this command:

During the installation you will see this message. Press 'y' when you do:

After that, you may see a message which will look like this:

Choose [a]lways by typing a and pressing Enter.

Note: You should choose 'y' and [a]lways if your application is using CI/CD pipeline because the interactive terminal is not available in that environment which will result in failure during the dependencies installation.

If you chose something else during the installation and API client doesn't work properly - please follow these instructions to fix the problem.

  1. Include the autoloader if it's not included, or you didn't use Composer before.

Replace path/to/vendor/autoload.php with the correct path to Composer's autoload.php.

Note: API client uses php-http/curl-client and nyholm/psr7 as a PSR-18, PSR-17 and PSR-7 implementation. You can replace those implementations during installation by installing this library with the implementation of your choice, like this:

More information about that can be found in the documentation.

Usage

Firstly, you should initialize the Client. The easiest way to do this is to use the SimpleClientFactory:

The client is separated into several resource groups, all of which are accessible through the Client's public properties. You can call API methods from those groups like this:

For example, you can retrieve the customers list:

Or the orders list:

To handle errors you must use two types of exceptions:

An example of error handling can be found in the next section of this document.

Each resource group is responsible for the corresponding API section. For example, costs resource group provide methods for costs manipulation and loyalty resource group allows interacting with loyalty programs, accounts, bonuses, etc.

Use annotations to determine which DTOs you need for sending the requests. If annotations are not provided by your IDE - you probably should configure them. It'll ease your work with this (and any other) library a lot.

More information about the usage including examples can be found in the documentation.

Examples

Listing orders:

Fetching a specific order by it's ID:

Creating a new customer:

Creating a task for the user with a specific email:

The error handling in the examples above is good enough for real production usage. You can safely assume that ApiExceptionInterface is an error from the API, and ClientExceptionInterface is a client error (e.g. network error or any runtime error, use HttpClientException to catch only PSR-18 client errors). However, you can implement more complex error handling if you want.

Also, both ApiExceptionInterface and ClientExceptionInterface implements __toString(). This means that you can just convert those exceptions to string and put the results into logs without any special treatment for the exception data.

More examples can be found in the documentation.

You can use a PSR-14 compatible event dispatcher to receive events from the client. See documentation for details.

Notes

This library uses HTTPlug abstractions. Visit official documentation to learn more about it.


All versions of api-client-php with dependencies

PHP Build Version
Package Version
Requires php Version >=7.3
ext-json Version *
psr/log Version ^1|^2|^3
psr/http-client Version ^1.0
psr/http-message Version ^1.0 || ^2.0
psr/http-message-implementation Version ^1.0
php-http/client-implementation Version ^1.0
php-http/message-factory Version ^1.0
php-http/discovery Version ^1.13
doctrine/annotations Version ^1.13|^2.0
liip/serializer Version 2.2.* || 2.6.*
php-http/httplug Version ^2.2
civicrm/composer-compile-plugin Version ^0.20
symfony/console Version ^4.0|^5.0|^6.0
psr/event-dispatcher Version ^1.0
neur0toxine/psr.http-client-implementation.php-http-curl Version *
neur0toxine/psr.http-factory-implementation.nyholm Version *
neur0toxine/psr.http-message-implementation.nyholm Version *
psr/cache Version ^1.0 || ^2.0 || ^3.0
symfony/cache Version >=v3.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 retailcrm/api-client-php contains the following files

Loading the files please wait ....