PHPackages                             stanley/geocodio-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. stanley/geocodio-php

Abandoned → [geocodio/geocodio-library-php](/?search=geocodio%2Fgeocodio-library-php)ArchivedLibrary[API Development](/categories/api)

stanley/geocodio-php
====================

Thin wrapper for the Geocodio API

1.9.0(7y ago)31301.6k—9.7%12MITPHPPHP &gt;=5.4.0

Since Jan 22Pushed 6y ago1 watchersCompare

[ Source](https://github.com/Geocodio/geocodio-php)[ Packagist](https://packagist.org/packages/stanley/geocodio-php)[ RSS](/packages/stanley-geocodio-php/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (9)Dependencies (2)Versions (18)Used By (0)

DEPRECATED
==========

[](#deprecated)

This library has been replaced by

geocod.io PHP
=============

[](#geocodio-php)

[![Build Status](https://camo.githubusercontent.com/8b47de9c19d6d8e2801cc7eb4422620234461085bc59befd5179047cce03a698/68747470733a2f2f7472617669732d63692e6f72672f47656f636f64696f2f67656f636f64696f2d7068702e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/Geocodio/geocodio-php)

Thin PHP wrapper for [geocod.io geocoding API](http://geocod.io/docs) that includes a service provider for Laravel.

Features
========

[](#features)

- Geocode an individual address
- Batch geocode up to 10,000 addresses at a time
- Parse an address into its identifiable components

Read the complete [geocod.io geocoding API](http://geocod.io/docs) for service documentation.

Installing via Composer
=======================

[](#installing-via-composer)

The recommended way to install geocod.io PHP is through [Composer](http://getcomposer.org).

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

# Add Geocodio as a dependency
php composer.phar require stanley/geocodio-php:~1.0
```

After installing, you need to require Composer's autoloader:

```
require('vendor/autoload.php');
```

Using
=====

[](#using)

Using the geocod.io PHP library is super simple.

```
require('vendor/autoload.php');
use Stanley\Geocodio\Client;

// Create the new Client object by passing in your api key
$client = new Client('YOUR_API_KEY');
```

> Note: Create an API key by signing up at

Geocode single address
----------------------

[](#geocode-single-address)

To encode a single address, simply pass a string to the `geocode` function.

```
$data = '123 Anywhere St, Chicago, IL';
$result = $client->geocode($data);
```

Geocode multiple addresses
--------------------------

[](#geocode-multiple-addresses)

For multiple addresses, you can pass an array of addresses to the same `geocode` function.

```
$data = [
  '123 Anywhere St, Chicago, IL',
  '456 Oak St, Los Angeles, CA'
];
$result = $client->geocode($data);
```

> Up to 10,000 addresses can be geocoded in a single *batch* request

Reverse geocoding a single coordinate
-------------------------------------

[](#reverse-geocoding-a-single-coordinate)

geocod.io also supports reverse geocoding. To convert a single lat/long pair into an address, call the 'reverse' method.

The lat/long pairs should be separateed by a comma.

```
$data = '35.9746000,-77.9658000';
$result = $client->reverse($data);
```

Reverse geocoding multiple coordinates
--------------------------------------

[](#reverse-geocoding-multiple-coordinates)

To do a batch conversion, pass your lat/long pairs in an array.

```
$data = [
    '35.9746000,-77.9658000',
    '32.8793700,-96.6303900',
    '33.8337100,-117.8362320',
    '35.4171240,-80.6784760'
];
$result = $client->reverse($data);
```

Fields
------

[](#fields)

Geocoding and reverse geocoding requests accepts an optional second parameter for [fields](https://geocod.io/docs/#fields).

```
$data = '123 Anywhere St, Chicago, IL';
$result = $client->geocode($data, ['cd', 'stateleg']);
```

```
$data = "35.9746000,-77.9658000";
$result = $client->reverse($data, ['cd', 'stateleg']);
```

```
$data = [
  '123 Anywhere St, Chicago, IL',
  '456 Oak St, Los Angeles, CA'
];
$result = $client->geocode($data, ['cd', 'stateleg']);
```

Return Values
-------------

[](#return-values)

The geocod.io PHP client will return an instance of the `Stanley\Geocodio\Data` class. The raw response body can be accessed from the `response` property. This property had the response data stored as an object.

```
$body = $address->response;
```

Laravel Service Provider and Facade
-----------------------------------

[](#laravel-service-provider-and-facade)

A service provder and facade are available if you are using Laravel. Once you've added the package to your composer.json file, run `php composer.phar update`. Add `'Stanley\Geocodio\ServiceProviders\LaravelServiceProvider'`to the `providers` key. Then, edit the `aliases` key and add `'Geocodio' => 'Stanley\Geocodio\Geocodio'` to the array.

You are now ready to use the Facade. If you are using Laravel, you will need to pass your API Key as the third parameter.

```
$fields = [];
$key = 'YOUR_API_KEY';
$data = Geocodio::get('123 Anywhere St, Chicago, IL', $fields, $key);
return response()->json($data);
```

Exceptions
----------

[](#exceptions)

Periodically, the geocod.io service will return [errors](https://geocod.io/docs/#errors).

To handle these:

- An HTTP 403 error raises a `GeocodioAuthError`
- An HTTP 422 error raises a `GeocodioDataError` and the error message will be reported through the exception
- An HTTP 5xx error raises a `GeocodioServerError`
- An unmatched non-200 response will simply raise `Exception`

Credits
-------

[](#credits)

The original library was written by [David Stanley](https://github.com/davidstanley01). Much of this readme and the structure of this library was inspired by the [Py-Geocodio Library](https://github.com/bennylope/pygeocodio) by [Ben Lopatin](https://github.com/bennylope).

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity45

Moderate usage in the ecosystem

Community18

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~132 days

Recently: every ~118 days

Total

16

Last Release

2564d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0060e8bb0ea0b060b82f54ca4e32fcc38ccb396eef281ec7200cb0012cbbbd68?d=identicon)[davidstanley01](/maintainers/davidstanley01)

---

Top Contributors

[![MiniCodeMonkey](https://avatars.githubusercontent.com/u/220535?v=4)](https://github.com/MiniCodeMonkey "MiniCodeMonkey (29 commits)")[![davidstanley01](https://avatars.githubusercontent.com/u/844070?v=4)](https://github.com/davidstanley01 "davidstanley01 (29 commits)")[![anthropos9](https://avatars.githubusercontent.com/u/3867685?v=4)](https://github.com/anthropos9 "anthropos9 (15 commits)")[![patrickcarlohickman](https://avatars.githubusercontent.com/u/6036266?v=4)](https://github.com/patrickcarlohickman "patrickcarlohickman (8 commits)")[![joshmoody](https://avatars.githubusercontent.com/u/1504862?v=4)](https://github.com/joshmoody "joshmoody (1 commits)")[![jgill-inhouse](https://avatars.githubusercontent.com/u/32556807?v=4)](https://github.com/jgill-inhouse "jgill-inhouse (1 commits)")[![tomschlick](https://avatars.githubusercontent.com/u/70184?v=4)](https://github.com/tomschlick "tomschlick (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/stanley-geocodio-php/health.svg)

```
[![Health](https://phpackages.com/badges/stanley-geocodio-php/health.svg)](https://phpackages.com/packages/stanley-geocodio-php)
```

###  Alternatives

[statamic/cms

The Statamic CMS Core Package

4.8k3.6M986](/packages/statamic-cms)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3741.3M46](/packages/tencentcloud-tencentcloud-sdk-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k38](/packages/neuron-core-neuron-ai)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

273.0k](/packages/eslazarev-wildberries-sdk)[avalara/avataxclient

Client library for Avalara's AvaTax suite of business tax calculation and processing services. Uses the REST v2 API.

528.5M7](/packages/avalara-avataxclient)[files.com/files-php-sdk

Files.com PHP SDK

2481.1k](/packages/filescom-files-php-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
