PHP code example of pgrimaud / sytadin

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

    

pgrimaud / sytadin example snippets


$api = new \Sytadin\Api();

$parameters = [
    'start' => 'orleans',
    'end' => 'bercy',
    'direction' => $api::DIRECTION_EXTERIOR
];

$api->setParameters($parameters);
$route = $api->getRoute();

echo $route->getStart()->getName() . PHP_EOL;
//orleans

echo $route->getEnd()->getName() . PHP_EOL;
//bercy

foreach ($route->getSections() as $section) {
    echo $section->getStart()->getName() . '->' . $section->getEnd()->getName() . PHP_EOL;
    echo $section->getTime() . ' (ref :' . $section->getTimeReference() . ')' . PHP_EOL;
}
//orleans->italie
//8 (ref :4)
//italie->bercy
//4 (ref :2)

//reference time
echo $route->getTimeReference() . PHP_EOL;
//6

//real time
echo $route->getTime() . PHP_EOL;
//12

//kilometers
echo $route->getKms() . PHP_EOL;
//8

foreach (\Sytadin\Gate::listGates() as $gate) {
    echo $gate . PHP_EOL;
}