PHP code example of shayanizadi / routific

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

    

shayanizadi / routific example snippets




$routific= new \Routific\ApiClient;
$routific->setApiKey('YOUR_API_KEY');

$order1 = array(
    "location" => array(
      "name" => "6800 Cambie",
      "lat" => 49.227107,
      "lng" => -123.1163085
));
$order2 = array(
    "location" => array(
      "name" => "3780 Arbutus",
      "lat" => 49.2474624,
      "lng" => -123.1532338
));
$order3 = array(
    "location" => array(
      "name" => "800 Robson",
      "lat" => 49.2819229,
      "lng" => -123.1211844
));
$visits = array(
    "order_1" => $order1,
    "order_2" => $order2,
    "order_3" => $order3
);

$routific->setVisits($visits);


$vehicle1 = array(
    "start_location" => array(
      "id" => "depot",
      "name" => "800 Kingsway",
      "lat" => 49.2553636,
      "lng" => -123.0873365
));
  
$vehicle2 = array(
    "start_location" => array(
      "id" => "depot",
      "name" => "800 Kingsway",
      "lat" => 49.2553636,
      "lng" => -123.0873365
));
  
$vehicles = array(
    "vehicle_1" => $vehicle1,
    "vehicle_2" => $vehicle2,
);

$routific->setVehicles($vehicles);


$routific->vehicleApi->optimizeRoute();

$routific->pickupDelivery->optimizeRoute();

$key=$routific->vehicleApi->optimizeRoute(TRUE);
 //OR
$key=$routific->pickupDelivery->optimizeRoute(TRUE);



$routific->jobApi->getJobDetails($key['job_id'])

bash

   composer dump-autoload