PHP code example of canaltp / tyr-component

1. Go to this page and download the library: Download canaltp/tyr-component 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/ */

    

canaltp / tyr-component example snippets

 php
$tyrUrl = 'http://tyr.dev.canaltp.fr/v0/';
$endPointId = 2;

// Instanciating api
$tyrApi = new CanalTP\TyrComponent\TyrService($tyrUrl, $endPointId); // For Guzzle5
$tyrApi = new CanalTP\TyrComponent\Guzzle3\TyrService($tyrUrl, $endPointId); // For Guzzle3

// Creating request
$user = $tyrApi->createUser('email', 'login');

// Get last Guzzle response instance (usefull to get status code...)
$response = $tyrApi->getLastResponse();
$statusCode = $response->getStatusCode();
 php
$tyrUrl = 'http://tyr.dev.canaltp.fr/v0/';
$endPointId = 2;

$tyrApi = new CanalTP\TyrComponent\TyrService($tyrUrl, $endPointId); // For Guzzle5
$tyrApi = new CanalTP\TyrComponent\Guzzle3\TyrService($tyrUrl, $endPointId); // For Guzzle3

// Creating GuzzleHttp\Client mock...

$tyrApi->setClient($mockedClient);