PHPackages                             chaplean/api-client-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. chaplean/api-client-bundle

AbandonedArchivedSymfony-bundle[API Development](/categories/api)

chaplean/api-client-bundle
==========================

Library to help defining client for rest apis

v1.3.0(6y ago)12.4k1[6 PRs](https://github.com/chaplean/api-client-bundle/pulls)5MITPHPPHP &gt;=7.0.8

Since Dec 11Pushed 3y ago1 watchersCompare

[ Source](https://github.com/chaplean/api-client-bundle)[ Packagist](https://packagist.org/packages/chaplean/api-client-bundle)[ RSS](/packages/chaplean-api-client-bundle/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (4)Dependencies (15)Versions (10)Used By (5)

Chaplean Api Client Bundle
==========================

[](#chaplean-api-client-bundle)

[![build status](https://camo.githubusercontent.com/c183b2679d3b357cdb6dae38986294800269c2669e1ed90b749672fdafdef2d2/68747470733a2f2f7472617669732d63692e6f72672f636861706c65616e2f6170692d636c69656e742d62756e646c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/chaplean/api-client-bundle)[![Coverage status](https://camo.githubusercontent.com/52ee51b8c1db93d0840e5f08ecc6dde215122b8a6b12c0c38adba486bf451b35/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f636861706c65616e2f6170692d636c69656e742d62756e646c652f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/chaplean/api-client-bundle?branch=master)[![contributions welcome](https://camo.githubusercontent.com/9e93e892d0685e1bf7a1d0bd7c8410d6ecf2086a0a7b48dd58a6b96fa556ea2a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f6e747269627574696f6e732d77656c636f6d652d627269676874677265656e2e7376673f7374796c653d666c6174)](https://github.com/chaplean/api-client-bundle/issues)

Library to help defining client for rest apis.

Table of content
----------------

[](#table-of-content)

- [Installation](#Installation)
- [Creating bundles based on api-client-bundle](#creating-bundles-based-on-api-client-bundle)
    - [Configuration](#Configuration)
    - [Creating an Api class](#creating-an-api-class)
    - [Defining an Api](#defining-an-api)
- [Using a bundle based on api-client-bundle](#using-a-bundle-based-on-api-client-bundle)
- [Additional Features](#additional-features)
- [Commands](#commands)
- [Versioning](#Versioning)
- [Contributing](#Contributing)
- [Hacking](#Hacking)
- [License](#License)

Installation
------------

[](#installation)

This bundle requires at least Symfony 3.0.

You can use [composer](https://getcomposer.org) to install api-client-bundle:

```
composer require chaplean/api-client-bundle
```

Then add to your AppKernel.php:

```
new EightPoints\Bundle\GuzzleBundle\EightPointsGuzzleBundle(),
new Chaplean\Bundle\ApiClientBundle\ChapleanApiClientBundle(),

// If you want to enable Database logging
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),

// If you want to enable Email logging
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle()
```

Creating bundles based on api-client-bundle
-------------------------------------------

[](#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](https://packagist.org/?query=chaplean%2F%20client-bundle) or [github](https://github.com/chaplean?utf8=%E2%9C%93&q=client-bundle&type=&language=).

### Configuration

[](#configuration)

First you will need to configure guzzlehttp that we use under the hood to perform the actual http requests. See the [bundle](https://github.com/8p/EightPointsGuzzleBundle) documentation or the [library](http://docs.guzzlephp.org/en/latest/request-options.html) documentation for the full range of options.

config.yml:

```
eight_points_guzzle:
    logging: true
    clients:
        fake_api:
            # We inject guzzle configuration from parameters.yml but we could hardcode it here
            options: %fake_api.options%
```

You will also probably want to create some custom parameters.

parameters.yml:

```
parameters:
    # Guzzle configuration
    fake_api.options:
        timeout: 10
        verify: false
        expect: false

    # Your custom configuration, here we just define the base url of our fake_api
    fake_api.url: 'http://fakeapi.com/'
```

As you inject guzzle in your Api class you can have different configuration per Api. See next [section](#creating-api).

### Creating an Api class

[](#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.

```
