Git Product home page Git Product logo

wsclientbundle's Introduction

this bundle is deprecated

usage of https://github.com/M6Web/GuzzleHttpBundle is recommended

Bundle WSClient Build Status

This bundle give a simple webservices client to call external urls. By default, it is based on Guzzle but you can plug any other client library.

Services

No default service is defined. You must set a configuration to instanciate one or more services.

Configuration

The main configuration key is m6_ws_client. Each subkey defines an instance of a webservice client. These services are named m6_ws_client_ + the subkey except for the default subkey that defines the main service m6_ws_client. For each instance, several parameters can be set :

  • base_url : the base domain of each url called with the service. If an absolute url is passed to the client, the base url is ignored.
  • config (optional) : additional parameters to configure the client, must be an array. See http://guzzle.readthedocs.org/en/latest/clients.html#request-options
  • cache (optional) :
    • ttl : 86400s by default. Max ttl if force_request_ttl is FALSE, forced ttl if force_request_ttl is TRUE
    • force_request_ttl (optional) : FALSE by default. If TRUE, request TTL is the same than the cache TTL, otherwise the request TTL is calculated according to response headers.
    • service : low level cache service (must implement M6Web\Bundle\WSClientBundle\Cache\CacheInterface)
    • adpater : adapter class name (must implement \Doctrine\Common\Cache\Cache)
    • storage : (optional) storage class name (must implement \GuzzleHttp\Subscriber\Cache\CacheStorageInterface)
    • subscriber : (optional) subscriber class (must implement \GuzzleHttp\Subscriber\Cache\SubscriberInterface)
    • can_cache : (optional) a callable to determine if a request can be cached

Here is an example of a simple configuration :

m6_ws_client:
    clients:
        default:
            base_url: 'toto.m6web.fr'
            config:
                timeout: 10
                allow_redirects: {max: 5, strict: false, referer: true}
                exceptions: false
            cache:
                ttl: 3600
                adapter: M6\Bundle\RedisBundle\Guzzle\RedisCacheAdapter
                service: m6_redis

Simple use case

For instance, in a controller :

$wsclient = $this->get('m6_ws_client');
$response = $wsclient->get('http://toto.m6web.fr/parse/?content=my_content');

echo $response->getBody();

unit test

composer install --dev
./bin/atoum

wsclientbundle's People

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

dipston logorn

wsclientbundle's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.