2017 © Pedro Peláez
 

library laravel-getaddress

Laravel Package for getaddress.io

image

szhorvath/laravel-getaddress

Laravel Package for getaddress.io

  • Thursday, April 19, 2018
  • by szhorvath
  • Repository
  • 0 Watchers
  • 0 Stars
  • 19 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 73 % Grown

The README.md

laravel-getaddress

Latest Version on Packagist ![Software License][ico-license] Build Status ![Coverage Status][ico-scrutinizer] Quality Score ![Total Downloads][ico-downloads], (*1)

Laravel-getaddress provides a wrapper around getaddress.io for laravel 5.4 and up. This package is based on PeteLawrence/getaddress PHP library., (*2)

Installation in Laravel 5.4

You can pull in the package via composer:, (*3)

$ composer require szhorvath/laravel-getaddress

You need to add Szhorvath\GetAddress\GetAddressServiceProvider to your config/app.php providers array:, (*4)

Szhorvath\GetAddress\GetAddressServiceProvider::class,

Add the following environmental variable to your .env file, (*5)

GETADDRESSIO_API_KEY=your-api-key

You must publish the config file:, (*6)

$ php artisan vendor:publish --provider="Szhorvath\GetAddress\GetAddressServiceProvider"

Installation in Laravel 5.5 and up

You can pull in the package via composer:, (*7)

$ composer require szhorvath/laravel-getaddress

The package will automatically register itself., (*8)

Add the following environmental variable to your .env file, (*9)

GETADDRESSIO_API_KEY=your-api-key

You must publish the config file:, (*10)

$ php artisan vendor:publish --provider="Szhorvath\GetAddress\GetAddressServiceProvider"

Usage

In a controller you can use the Facade. The GetAddress always returns an array, (*11)

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Szhorvath\GetAddress\Facades\GetAddress;

class AddressController extends Controller
{
    public function lookup()
    {
        $result = GetAddress::lookup('S20 8JH');

        $longitude = $result->getLongitude();
        $latitude = $result->getLatitude();
        $addressList = $result->getAddresses();

        foreach ($addressList as $key => $address) {
            $line1 = $address->getLine1();
            $line2 = $address->getLine2();
            $line3 = $address->getLine3();
            $line4 = $address->getLine4();
            $town  = $address->getTown();
            $postalTown = $address->getPostalTown();
            $normalisedTown = $address->getNormalisedTown();
            $county = $address->getCounty();
            #Full address as comma separated string
            $csv = $address->toCsv();
        }

        #Or for a specific address you can pass the house number or name as second parameter
        $result = GetAddress::lookup('S20 8JH', 5);
        if ($address = $result->getAddress()) {
            $town  = $address->getTown();
        };
    }
}

Change log

Please see CHANGELOG for more information on what has changed recently., (*12)

Testing

$ composer test

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details., (*13)

Security

If you discover any security related issues, please email z.sandor.horvath@gmail.com instead of using the issue tracker., (*14)

Credits

License

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

The Versions

19/04 2018

dev-master

9999999-dev https://github.com/szhorvath/laravel-getaddress

Laravel Package for getaddress.io

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel getaddress.io getaddress laravel-getaddress addess lookup

19/04 2018

1.0.1

1.0.1.0 https://github.com/szhorvath/laravel-getaddress

Laravel Package for getaddress.io

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel getaddress.io getaddress laravel-getaddress addess lookup

19/04 2018

1.0.0

1.0.0.0 https://github.com/szhorvath/laravel-getaddress

Laravel Package for getaddress.io

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel getaddress.io getaddress laravel-getaddress addess lookup

18/04 2018

0.0.1

0.0.1.0 https://github.com/szhorvath/laravel-getaddress

Laravel Package for getaddress.io

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel getaddress.io getaddress laravel-getaddress addess lookup