PHP code example of leaseweb / guzzle-bundle

1. Go to this page and download the library: Download leaseweb/guzzle-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

leaseweb / guzzle-bundle example snippets

 bash
$ php composer.phar update leaseweb/guzzle-bundle
 php

// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Lsw\GuzzleBundle\LswGuzzleBundle(),
    );
}
 php
 phpinfo() 

lsw_guzzle:
    clients:
        test:
            config:
                json_objects: true
                curl.options:
                    CURLOPT_CONNECTTIMEOUT: 10
                    CURLOPT_SSL_VERIFYPEER: false
                    CURLOPT_USERAGENT: "LeaseWeb API Caller"
                    CURLOPT_FOLLOWLOCATION: true
                    CURLOPT_SSLVERSION: 3
            description:
                baseUrl: "http://sf2testproject.dev"
                operations: 
                    test: 
                        httpMethod: "GET"
                        uri: "/app_dev.php/demo/?a=b"
                    json: 
                        httpMethod: "GET"
                        uri: "/app_dev.php/demo/json"
                    json_post: 
                        httpMethod: "POST"
                        uri: "/app_dev.php/demo/{action}"
                        parameters:
                            testvalue:
                                location: xml
                            action:
                                location: uri

    	$response = $this->get('guzzle.test')->getCommand('test')->execute();
    	$response = $this->get('guzzle.test')->getCommand('json')->execute();
    	$response = $this->get('guzzle.test')->getCommand('json_post',array('action'=>'json','testvalue'=>666))->execute();