Search by

1tomany / php-geocoder

viccherubini

A simple framework-independent geocoding library

Package info

github.com/1tomany/php-geocoder

pkg:composer/1tomany/php-geocoder

Statistics

Installs: 22

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

v0.0.4 2026-09-02 06:26 UTC

This package is auto-updated.

Last update: 2026-09-02 06:27:27 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

<?php

use OneToMany\Geocoder\Bridge\Google\GoogleProvider;
use OneToMany\Geocoder\Bridge\Mock\MockProvider;
use OneToMany\Geocoder\Bridge\Transport;
use OneToMany\Geocoder\GeocodingClient;
use OneToMany\Geocoder\GeocodingVendor;
use OneToMany\Geocoder\Resource\ForwardGeocode;
use OneToMany\Geocoder\Resource\ReverseGeocode;

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

$googleApiKey = getenv('GOOGLE_API_KEY');

$client = new GeocodingClient([
    new GoogleProvider(
        $transport,
        $googleApiKey,
    ),
    new MockProvider(),
]);

$response = $client->forward(
    GeocodingVendor::Google,
    new ForwardGeocode(
        '123',
        'Main Street',
        null,
        'Dallas',
        '75205',
        'TX',
        'US',
    ),
);

$response = $client->reverse(
    GeocodingVendor::Google,
    new ReverseGeocode(
        '32.10391494',
        '-96.3931030',
    ),
);

Credits

License

The MIT License