antonamosov / laravel-getting-locations
获取存储在预定义格式中的JSON编码位置数据的工具。
dev-master
2018-12-22 14:40 UTC
Requires
- guzzlehttp/guzzle: ~6.0
- illuminate/support: ~5
Requires (Dev)
- phpunit/phpunit: ~7.0
This package is not auto-updated.
Last update: 2024-09-23 07:14:00 UTC
README
一个用于通过自定义服务获取位置的laravel包。
安装
使用以下命令使用composer安装此包
$ composer require "antonamosov/laravel-getting-locations @dev"
更新composer后,将服务提供者添加到config/app.php文件中的providers数组中
Antonamosov\LaravelGettingLocations\LaravelGettingLocationsServiceProvider::class,
并将别名添加到config/app.php文件中的aliases数组中
'GettingLocations' => Antonamosov\LaravelGettingLocations\Facades\LaravelGettingLocations::class,
发布配置文件以更改实现、选择服务和API密钥
$ php artisan vendor:publish --provider="Antonamosov\LaravelGettingLocations\LaravelGettingLocationsServiceProvider" --tag="config"
用法
use LaravelGettingLocations; $response = LaravelGettingLocations::getLocations([ 'name' => 'Moscow City', 'address' => 'Lenina', 'postalCode' => '185000', 'country' => 'Russia', ]); if ($response->success) { foreach ($response->data->locations as $location) { echo $location->name . "\n"; echo $location->coordinates->lat . "\n"; echo $location->coordinates->long . "\n\n"; } }
测试
./vendor/bin/phpunit vendor/antonamosov/laravel-getting-locations/tests/LaravelGettingLocationsTest.php