PHP code example of plutuss / laravel-geonames-api
1. Go to this page and download the library: Download plutuss/laravel-geonames-api library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
plutuss / laravel-geonames-api example snippets
$response = GeoName::postalCodeSearchJSONFromName('city_name');
$response = GeoName::setPostalCode(6600)
->setCountryCode('CH')
->postalCodeSearchJSONFromName('city_name');
// OR
$response = GeoName::setOption([
'country' => 'CH',
])->postalCodeSearchJSONFromName('city_name');
$response = GeoName::postalCodeSearchJSONFromPostCode(6600);
$response = GeoName::setCountryCode('CH')
->postalCodeSearchJSONFromPostCode(6600);
// OR
$response = GeoName::setOption([
'country' => 'CH',
])->postalCodeSearchJSONFromPostCode('6600');
setCountryCode(string $countryCode): static;
setPostalCode(int $value): static;
setPostalCodeStartsWith(string $value): static;
setPlaceName(string $value): static;
setPlaceNameStartsWith(string $value): static;
setCountry(string $value): static;
setCountryBias(string $value): static;
setMaxRows(int $value): static;
setStyle(string $value): static;
setOperator(string $value): static;
setCharset(string $value): static;
setIsReduced(bool $value): static;
setEast(float $value): static;
setWest(float $value): static;
setNorth(float $value): static;
setSouth(float $value): static;
setLatitude(string $value): static;
setLongitude(string $value): static;
setRadius(int $value): static;
setOption(array $params): static;
searchJSON(string $country): JsonResponse|array|Collection;
postalCodeSearchJSONFromPostCode(int $postalCode, int $radius = 5, int $maxRows = 10): JsonResponse|array|Collection;
postalCodeSearchJSONFromName(string $name, int $radius = 5, int $maxRows = 10): JsonResponse|array|Collection;
findNearbyPostalCodes(int $lat, int $lng): JsonResponse|array|Collection;
postalCodeCountryInfo(): JsonResponse|array|Collection;
findNearbyJSON(int $lat, int $lng): JsonResponse|array|Collection;
latitude(): mixed;
getCollectionData(): Collection;
getArrayData(): array;
longitude(): mixed;
placeName(): mixed;
postalCode(): mixed;
countryCode(): mixed;
region(): mixed;
land(): mixed;
// The getNestedValue() method retrieves a value
// from a deeply nested array using "dot" notation
// $response->getNestedValue('key.array')
getNestedValue($path, $default = null): mixed;
shell
php artisan vendor:publish --provider="Plutuss\GeoNames\Providers\GeoNamesServiceProvider"