businessprocess/geo-service-sdk

Geo service sdk for php

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

This package is auto-updated.

Last update: 2025-03-01 00:31:57 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 is a PSR-compatible PHP package for working with geo service api.

API Documentation

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