承接 szhorvath/laravel-getaddress 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

szhorvath/laravel-getaddress

Composer 安装命令:

composer require szhorvath/laravel-getaddress

包简介

Laravel Package for getaddress.io

README 文档

README

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

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

Installation in Laravel 5.4

You can pull in the package via composer:

$ composer require szhorvath/laravel-getaddress

You need to add Szhorvath\GetAddress\GetAddressServiceProvider to your config/app.php providers array:

Szhorvath\GetAddress\GetAddressServiceProvider::class,

Add the following environmental variable to your .env file

GETADDRESSIO_API_KEY=your-api-key

You must publish the config file:

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

Installation in Laravel 5.5 and up

You can pull in the package via composer:

$ composer require szhorvath/laravel-getaddress

The package will automatically register itself.

Add the following environmental variable to your .env file

GETADDRESSIO_API_KEY=your-api-key

You must publish the config file:

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

Usage

In a controller you can use the Facade. The GetAddress always returns an array

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.

Testing

$ composer test

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details.

Security

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

Credits

License

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

统计信息

  • 总下载量: 1.21k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-04-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固