1tomany/php-geocoder

A simple framework-independent geocoding library

Maintainers

Package info

github.com/1tomany/php-geocoder

pkg:composer/1tomany/php-geocoder

Transparency log

Statistics

Installs: 4

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

v0.0.1 2026-08-21 06:49 UTC

This package is auto-updated.

Last update: 2026-08-21 07:02:50 UTC


README

This package provides a simple framework-independent geocoding library.

Installation

Install the library using Composer:

composer require 1tomany/php-geocoder

Symfony Bundle

A Symfony bundle is available if you wish to integrate this library into your Symfony applications with autowiring and configuration support.

Supported platforms

  • Google
  • Mock

Usage

use OneToMany\Geocoder\Bridge\Google\GoogleProvider;
use OneToMany\Geocoder\Bridge\Mock\MockProvider;
use OneToMany\Geocoder\Bridge\Transport;
use OneToMany\Geocoder\GeocoderClient;
use OneToMany\Geocoder\Resource\Geocode;
use OneToMany\Geocoder\Resource\Reverse;
use OneToMany\Geocoder\Vendor;

$transport = new Transport(
    createSymfonyHttpClient(),
    createSymfonySerializer(),
);

$googleApiKey = getenv('GOOGLE_API_KEY');

$geocoderClient = new GeocoderClient([
    new GoogleProvider(
        transport: $transport,
        apiKey: $googleApiKey,
    ),
    new MockProvider(),
]);

$response = $geocoderClient->geocode(
    Vendor::Google,
    new Geocode(
        street: '123 Main Street',
        unit: null,
        city: 'Dallas',
        zip: '75205',
        state: 'TX',
        country: null,
    ),
);

$response = $geocoderClient->reverse(
    Vendor::Google,
    new Reverse(
        latitude: 32.10391494,
        longitude: -96.3931030,
    ),
);

Credits

License

The MIT License