Download the PHP package chaplean/api-client-bundle without Composer

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

Chaplean Api Client Bundle

build status Coverage status contributions welcome

Library to help defining client for rest apis.

Table of content

Installation

This bundle requires at least Symfony 3.0.

You can use composer to install api-client-bundle:

Then add to your AppKernel.php:

Creating bundles based on api-client-bundle

This section describes how you can create your own api bundle based on this project. If you want examples see our own api bundles on packagist or github.

Configuration

First you will need to configure guzzlehttp that we use under the hood to perform the actual http requests. See the bundle documentation or the library documentation for the full range of options.

config.yml:

You will also probably want to create some custom parameters.

parameters.yml:

As you inject guzzle in your Api class you can have different configuration per Api. See next section.

Creating an Api class

To use api-client-bundle you have to create a class extending AbstractApi. You can create any number of classes extending AbstractApi and have all of them using different configurations via dependency injection.

And we're done! We could repeat this process to create another Api with completely different configurations.

Defining an Api

Let's focus on the function you have to fill in and what we can do in it. The role of this function is to define your Api using the api-client-bundle's api:

Parameter options

List of options for the parameters

Using a bundle based on api-client-bundle

This section describes how to use a bundle based api-client-bundle.

As shown in the previous section the api defines a list of routes and the parameters they accept. To call a route you need to provide them.

For an api with the following definition:

We can call the getUser() method, provide the parameters and run the request:

Here we called bindUrlParameters() to provide values for the parameters defined with urlParameters(). Similarly, for parameters defined with headers(), queryParameters() and requestParameters() there is a bindHeaders(), bindQueryParameters() and bindRequestParameters().

You have to call these functions with a key => value array. There is a validation pass during exec() before running the request making sure the values you provided match the definitions in the api.

Finally, exec() returns a ResponseInterface. Several implementations of this interface exist:

Among the functions in ResponseInterface here are some usefull ones and how you could use them:

Additional Features

This bunde expose some configuration if you want to enable extra features. You can enable database and / or email logging of requests. To use the database or email loggers you will have to setup respectively doctrine or swiftmailer in your project. The default configuraton is:

config.yml:

You can override the default email content by overriding the translation keys or even the email body twig template. The translation keys are under chaplean_api_client.email.request_executed_notification and the template is Resources/views/Email/request_executed_notification.txt.twig.

Commands

To clean the logs from the Database, you may use the command chaplean:api-logs:clean [minimumDate]. It will remove old logs, only keeping those more recent than the given minimumDate date. By default, this argument date is now -1 month. It should be formatted as a PHP's DateTime string.

This command makes irreversible changes in your database, so we strongly recommend you to back up the logs before executing it.

Versioning

api-client-bundle follows semantic versioning. In short the scheme is MAJOR.MINOR.PATCH where

  1. MAJOR is bumped when there is a breaking change,
  2. MINOR is bumped when a new feature is added in a backward-compatible way,
  3. PATCH is bumped when a bug is fixed in a backward-compatible way.

Versions bellow 1.0.0 are considered experimental and breaking changes may occur at any time.

Contributing

Contributions are welcomed! There are many ways to contribute, and we appreciate all of them. Here are some of the major ones:

As a reminder, all contributors are expected to follow our Code of Conduct.

Hacking

You might find the following commands usefull when hacking on this project:

License

api-client-bundle is distributed under the terms of the MIT license.

See LICENSE for details.


All versions of api-client-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0.8
eightpoints/guzzle-bundle Version ^7.0
symfony/config Version ^3.0 || ^4.0
symfony/console Version ^3.0 || ^4.0
symfony/dependency-injection Version ^3.0 || ^4.0
symfony/yaml Version ^3.0 || ^4.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 chaplean/api-client-bundle contains the following files

Loading the files please wait ....