programic/laravel-distance-matrix

Using Google Distance Matrix in Laravel

v1.1.0 2023-04-26 06:36 UTC

This package is auto-updated.

Last update: 2024-05-26 08:54:38 UTC


README

Latest Version on Packagist Total Downloads

This package allows you to use get simple the duration and distance between two addresses by the Google Distance Matrix API

Installation

This package requires PHP 7.2 and Laravel 5.8 or higher.

composer require programic/laravel-distance-matrix

Basic Usage

use \Programic\DistanceMatrix\DistanceMatrix

class DistanceController {

    public function index(DistanceMatrix $distanceMatrix)
    {
        $response = $distanceMatrix->from($from)->to($to)->calculate();
        
        $distance = $response->toArray();
    }
    
} 

Available Exceptions

See the Exceptions folder for more information. Except for the InvalidKeyException, these Exceptions are all taken from the Google Distance Matrix API documentation.

use Programic\DistanceMatrix\Exceptions\InvalidKeyException;
use Programic\DistanceMatrix\Exceptions\InvalidRequestException;
use Programic\DistanceMatrix\Exceptions\MaxDimensionsExceededException;
use Programic\DistanceMatrix\Exceptions\MaxElementsExceededException;
use Programic\DistanceMatrix\Exceptions\OverDailyLimitException;
use Programic\DistanceMatrix\Exceptions\OverQueryLimitException;
use Programic\DistanceMatrix\Exceptions\RequestDeniedException;
use Programic\DistanceMatrix\Exceptions\UnknownErrorException;

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security-related issues, please email info@programic.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.