PHP code example of calcinai / siri
1. Go to this page and download the library: Download calcinai/siri 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/ */
calcinai / siri example snippets
use Calcinai\Siri\Objects\Siri;
use Calcinai\Siri\Objects\ServiceRequest;
use Calcinai\Siri\Objects\VehicleMonitoringRequest;
use Calcinai\Siri\Serializer
$requestTimestamp = new DateTime();
$siri = new Siri();
$request = new ServiceRequest();
$vmRequest = new VehicleMonitoringRequest();
$siri->setVersion(1.3)
->setServiceRequest($request);
$vmRequest->setVersion(1.3)
->setVehicleRef('3706')
->setRequestTimestamp($requestTimestamp);
$request->setVehicleMonitoringRequest($vmRequest)
->setRequestTimestamp($requestTimestamp)
->setRequestorRef('Requestor');
$serializer = new Serializer();
$xml = $serializer->serialize($siri);
echo $xml;
$siri = $serializer->deserialize($xml);
print_r($siri); //The root siri object