The Routific PHP library provides convenient access to the Routific API from applications written in the PHP language. It includes a pre-defined set of classes for API resources that initialize themselves dynamically from API responses.
PHP 7.2.0 and later.
You can install the bindings via Composer. Run the following command:
composer require shayanizadi/routific
To use the bindings, use Composer's autoload:
require_once('vendor/autoload.php');
Simply set your Routific API key:
$routific= new \Routific\ApiClient;
$routific->setApiKey('YOUR_API_KEY');
See the Routific API docs.
First step you must set up your visit endpoints :
$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);
Then you can define your vehicles (drivers) :
$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);
Now you can choose based on your purpose to use API that suits your situation
If you want use just vehicle routing optimization:
$routific->vehicleApi->optimizeRoute();
If you are looking for Pickup and Delivery optimizer :
$routific->pickupDelivery->optimizeRoute();
If you wish to use Long Running Tasks Api, you have to simply set input for optimizeRoute as TRUE:
$key=$routific->vehicleApi->optimizeRoute(TRUE);
//OR
$key=$routific->pickupDelivery->optimizeRoute(TRUE);
Then you have to retrieve job that has been created:
$routific->jobApi->getJobDetails($key['job_id'])
We welcome contributions from everyone! If you'd like to contribute to this project, follow these steps:
1- Fork the repository. 2- Create a new branch for your feature or bug fix 3- Commit your changes and push your branch 4- Open a pull request and explain your changes.
Your contributions will help make this project even better. Thank you for your support!
This project is licensed under the MIT License. You are free to use, modify, and distribute this project as long as you include the original license file. For more details, see the LICENSE file .