businessprocess / geo-service-sdk
Geo service sdk for php
Installs: 4 709
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: ^7.4|^8.0
- ext-json: *
- guzzlehttp/guzzle: ^7.0
Requires (Dev)
- laravel/framework: ^9.0
- laravel/pint: ^1.1
- phpunit/phpunit: ^9.3.3
README
Geo Service SDK is a PSR-compatible PHP package for working with geo service api.
Installation
The recommended way to install Geo service is through Composer.
# Install Composer curl -sS https://getcomposer.org/installer | php
Next, run the Composer command to install the latest stable version of Guzzle:
composer require businessprocess/geo-service-sdk
After installing, you need to require Composer's autoloader:
require 'vendor/autoload.php';
You can then later update Guzzle using composer:
composer update
Usage
$client = new \GeoService\Service\GeoService(); // set locale if we need $client->setLocale('en') $response = $client->countries(); print $response->all(); # '[{"id": ...}'
Usage 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');
Available Methods
Methods | Description | Return value |
---|---|---|
getCountryWithCities | Get all countries with children | Collection |
countries | Get all countries without details | Collection |
country | Get country by id | Country |
getCitiesByCountry | Get cities by country id | Collection |
getById | Get model by id | BaseModel |
getChildById | Get all children by parent id | Collection |
getCountryByCode | Get country by code | Country |
getCitiesByCode | Get cities by country code | Collection |
search | Get all model by keyword | Collection |
ping | Ping node | boolean |
alive | Check is node is alive | boolean |
isServiceId | Check is id belongs to geo service | boolean |