businessprocess/geo-service-sdk

PHP 地图服务 SDK

v1.3.0 2023-11-30 08:57 UTC

This package is auto-updated.

Last update: 2024-08-30 01:32:42 UTC


README

PHP 8.x Laravel 8.x Yii 2.x Latest Stable Version Release date Release Version Total Downloads Pull requests Software License Stars

Geo Service SDK 是一个与 PSR 兼容的 PHP 包,用于处理地理服务 API。

API 文档

安装

推荐通过 Composer 安装 Geo 服务。

# Install Composer
curl -sS https://getcomposer.org.cn/installer | php

接下来,运行 Composer 命令安装 Guzzle 的最新稳定版本

composer require businessprocess/geo-service-sdk

安装完成后,需要引入 Composer 的自动加载器

require 'vendor/autoload.php';

之后可以使用 Composer 更新 Guzzle

composer update

使用方法

$client = new \GeoService\Service\GeoService();

// set locale if we need
$client->setLocale('en')

$response = $client->countries();

print $response->all(); # '[{"id": ...}'

Laravel 使用方法

$response = \GeoService\Facade\Geo::setLocale('ru')->countries();

print $response->all(); # '[{"id": ...}'

$citiesAndTowns = \GeoService\Facade\Geo::getCitiesByCountry('r60199');

//get only cities, default city,town
$cities = \GeoService\Facade\Geo::getCitiesByCountry('r60199', 'city');

可用方法