ashleighsims/get-address-wrapper
Composer 安装命令:
composer require ashleighsims/get-address-wrapper
包简介
Get Address IO wrapper covering all endpoints available from the API.
README 文档
README
A simple wrapper for the GetAddress IO service. Allowing the retrieval of address information from the provided post code. as well as other services.
Installation
Before you can start using GetAddress IO you will need to register for an API key. There is a free API key that you can use for 30 days before moving onto a paid plan.
You can get an API key and find out more information here: https://getaddress.io/
Via Composer
$ composer require ashleighsims/get-address-wrapper
Laravel
If you're using this package in Laravel auto discovery has been enabled so you should be able to hit the ground running (when using Laravel 5.5 and beyond)
if you aren't using Laravel 5.5 and above you will need to manually register some bits...
Register the provider in the app.php file:
AshleighSims\GetAddressWrapper\Laravel\GetAddressWrapperServiceProvider::class
Optionally register the Facade:
'GetAddress' => AshleighSims\GetAddressWrapper\Laravel\GetAddressWrapperServiceProvider::class
Please ensure you've added the below environment variables to your .env file before starting.
Environment Variables
Add the following environment variables to your .env file.
GET_ADDRESS_BASE_URL="https://api.getaddress.io" GET_ADDRESS_API_KEY="" GET_ADDRESS_ADMINISTRATION_API_KEY="" GOOGLE_PLACES_API_KEY=""
Usage
Laravel
Dependency Injection Via Controller
use AshleighSims\GetAddressWrapper\GetAddressWrapper; ... private $getAddress; public function __construct(GetAddressWrapper $getAddress) { $this->getAddress = $getAddress; } public function getPostcodeAddressList() { $response = $this->getAddress->findByPostcode()->find('SW1A 1AA'); } ...
Facade
use AshleighSims\GetAddressWrapper\Laravel\Facades\GetAddressWrapper; ... public function getAddress() { $response = GetAddressWrapper::findByPostcode()->find('SW1A 1AA'); } ...
General Usage
Find
List of addresses from postcode
$getAddress = new GetAddressWrapper('api-key', 'admin-api-key', 'google-places-api-key', 'https://api.getAddress.io'); $response = $getAddress->findByPostcode()->find('SW1A 1AA');
Return: Array of AshleighSims\GetAddressWrapper\Response\Address Objects
Address from postcode and building number
$getAddress = new GetAddressWrapper('api-key', 'admin-api-key', 'google-places-api-key', 'https://api.getAddress.io'); $response = $getAddress->findByPostcode()->findWithNumber('SW1A 1AA', 'Buckingham Palace');
Return: Object AshleighSims\GetAddressWrapper\Response\Address
Distance
$getAddress = new GetAddressWrapper('api-key', 'admin-api-key', 'google-places-api-key', 'https://api.getAddress.io'); $response = $getAddress->distance()->between('SW1A 1AA', 'SL4 1QF');
Return: Object AshleighSims\GetAddressWrapper\Response\Distance
Autocomplete - Postcodes
$getAddress = new GetAddressWrapper('api-key', 'admin-api-key', 'google-places-api-key', 'https://api.getAddress.io'); $response = $getAddress->autoCompletePostcode()->complete('SW1A');
Return: Object AshleighSims\GetAddressWrapper\Response\GooglePlacesPostcodePrediction
Autocomplete - Places
Places
$getAddress = new GetAddressWrapper('api-key', 'admin-api-key', 'google-places-api-key', 'https://api.getAddress.io'); $response = $getAddress->>autoCompletePlaces()->complete('Buckingham');
Return: Array of AshleighSims\GetAddressWrapper\Response\GooglePlacesPrediction Objects
Place Details
$getAddress = new GetAddressWrapper('api-key', 'admin-api-key', 'google-places-api-key', 'https://api.getAddress.io'); $response = $getAddress->autoCompletePlaces()->findByGooglePlacesId('ChIJtV5bzSAFdkgRpwLZFPWrJgo');
Return: Object AshleighSims\GetAddressWrapper\Response\GooglePlace
Usage
Current day
$getAddress = new GetAddressWrapper('api-key', 'admin-api-key', 'google-places-api-key', 'https://api.getAddress.io'); $response = $getAddress->usage()->get();
Return: Object AshleighSims\GetAddressWrapper\Response\Usage
Given date
$getAddress = new GetAddressWrapper('api-key', 'admin-api-key', 'google-places-api-key', 'https://api.getAddress.io'); $response = $getAddress->usage()->getByDate('18/02/2020', 'd/m/Y');
Return: Object AshleighSims\GetAddressWrapper\Response\Usage
Date range
$getAddress = new GetAddressWrapper('api-key', 'admin-api-key', 'google-places-api-key', 'https://api.getAddress.io'); $response = $getAddress->usage()->getBetween('18/02/2020', '19/02/2020', 'd/m/Y');
Return: Array of AshleighSims\GetAddressWrapper\Response\DailyUsage Objects
Private Address List
Add address
$getAddress = new GetAddressWrapper('api-key', 'admin-api-key', 'google-places-api-key', 'https://api.getAddress.io'); $response = $getAddress->privateAddress()->add('SW1A 1AA', [ 'line1' => 'Ashleigh\'s Palace', 'line2' => '', 'line3' => '', 'line4' => '', 'locality' => '', 'townOrCity' => 'London', 'county' => '', ]);
Return: JSON decoded associative array
Delete address
$getAddress = new GetAddressWrapper('api-key', 'admin-api-key', 'google-places-api-key', 'https://api.getAddress.io'); $response = $getAddress->privateAddress()->delete('SW1A 1AA', '1');
Return: JSON decoded associative array
Get address
$getAddress = new GetAddressWrapper('api-key', 'admin-api-key', 'google-places-api-key', 'https://api.getAddress.io'); $response = $getAddress->privateAddress()->get('SW1A 1AA', '1');
Return: Object AshleighSims\GetAddressWrapper\Response\PrivateAddress
List addresses
$getAddress = new GetAddressWrapper('api-key', 'admin-api-key', 'google-places-api-key', 'https://api.getAddress.io'); $response = $getAddress->privateAddress()->list('SW1A 1AA');
Return: Array of AshleighSims\GetAddressWrapper\Response\PrivateAddress Objects
Change log
Please see the changelog for more information on what has changed recently.
Security
If you discover any security related issues, please email sims@ashleighsims.co.uk instead of using the issue tracker.
License
license. Please see the license file for more information.
ashleighsims/get-address-wrapper 适用场景与选型建议
ashleighsims/get-address-wrapper 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 561 次下载、GitHub Stars 达 4, 最近一次更新时间为 2020 年 02 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「Get Address IO」 「Postcode Address Lookup」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ashleighsims/get-address-wrapper 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ashleighsims/get-address-wrapper 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ashleighsims/get-address-wrapper 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Maps in minutes. Powered by the Google Maps API.
Redirects TYPO3 visitors automatic or with a suggestlink to another language and/or root page.
Module adding custom shipping attribute for what3words address
A modern, feature-rich Laravel package for managing addresses with geocoding, validation, caching, and spatial operations. Perfect for e-commerce, CRM systems, and any application requiring robust address management.
This package provides an Address Model, Migration and Factory. It also provides the traits HasBillingAddres and HasPublicAddress
Symfony Postcode bundle
统计信息
- 总下载量: 561
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-02-19