PHPackages                             dsyph3r/google-geolocation-bundle - 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. dsyph3r/google-geolocation-bundle

AbandonedArchivedSymfony-bundle

dsyph3r/google-geolocation-bundle
=================================

Google Geolocaton integration for your Symfony2 project

3218.7k16[2 PRs](https://github.com/dsyph3r/GoogleGeolocationBundle/pulls)PHP

Since Aug 18Pushed 9y ago4 watchersCompare

[ Source](https://github.com/dsyph3r/GoogleGeolocationBundle)[ Packagist](https://packagist.org/packages/dsyph3r/google-geolocation-bundle)[ RSS](/packages/dsyph3r-google-geolocation-bundle/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Google Geolocation Bundle for Symfony2
======================================

[](#google-geolocation-bundle-for-symfony2)

Overview
--------

[](#overview)

A Symfony 2 bundle for the [Google Geocoding API](http://code.google.com/apis/maps/documentation/geocoding/)service.

Requirements
------------

[](#requirements)

- PHP 5.3+

Dependancies
------------

[](#dependancies)

- [Buzz](https://github.com/kriswallsmith/Buzz)

Installation
------------

[](#installation)

1. Add bundle and Buzz library dependancy to `vendor` dir:

    - Using vendors script

        Add the following to the `deps` file:

        ```
          [Buzz]
              git=git://github.com/kriswallsmith/Buzz.git
              target=/Buzz

          [GoogleGeolocationBundle]
              git=git://github.com/dsyph3r/GoogleGeolocationBundle.git
              target=/bundles/Google/GeolocationBundle

        ```

        Run the vendors script:

        ```
          $ php bin/vendors install

        ```
    - Using git submodules:

        ```
          $ git submodule add git://github.com/kriswallsmith/Buzz.git vendor/Buzz
          $ git submodule add git://github.com/dsyph3r/GoogleGeolocationBundle.git vendor/bundles/Google/GeolocationBundle

        ```
2. Add the Google and Network namespace to your autoloader:

    ```
     // app/autoload.php
     $loader->registerNamespaces(array(
         // ..
         'Buzz'      => __DIR__.'/../vendor/Buzz/lib',
         'Google'    => __DIR__.'/../vendor/bundles',
     ));

    ```
3. Add bundle to application kernel:

    ```
     // app/ApplicationKernel.php
     public function registerBundles()
     {
         return array(
             // ...
             new Google\GeolocationBundle\GoogleGeolocationBundle(),
         );
     }

    ```

Usage
-----

[](#usage)

The bundle provides a service available via the `google_geolocation.geolocation_api`identifier.

To retrieve the service from the container:

```
$geo = $this->get('google_geolocation.geolocation_api');

```

### Basic usage

[](#basic-usage)

To find an address:

```
$geolocationApi = $this->get('google_geolocation.geolocation_api');
$location = $geolocationApi->locateAddress("Wales, UK");

if ($location->getMatches() > 0)
{
    $matches = json_decode($location->getResult(), true);

    // Get address components [city, country, postcode, etc] for 1st match
    $components = $location->getAddressComponents(0);

    // Get LatLng for 2nd match
    $latLng = $location->getLatLng(1);
}

```

### Additional Usage

[](#additional-usage)

The service can be used in 2 ways:

1. Without the caching layer (default)
2. With the caching layer

#### Without the caching layer

[](#without-the-caching-layer)

The service is configured by default to not use the caching layer.

#### With the caching layer

[](#with-the-caching-layer)

The caching layer provides a cache of previous requests made to the Google Geocoding API to reduce the number of requests required for the service. It also allows limiting of requests made to the service. Both of these features are useful if you heavily use the Google Geocoding API.

To enable the use of the caching layer you need to configure the service. Update the config at `app/config/config.yml` with the following:

```
services:
    google_geolocation.geolocation_api:
        class:      %google_geolocation.geolocation_api.class%
        calls:
            - [ setEntityManager, [ @doctrine.orm.entity_manager ] ]
            - [ setDailyLimit, [ %google_geolocation.geolocation_api.daily_limit% ] ]
            - [ setCacheLifetime, [ %google_geolocation.geolocation_api.cache_lifetime% ] ]

```

The defaults for the paramaters are as follows:

```
google_geolocation.geolocation_api.daily_limit: 2500    # Daily requests
google_geolocation.geolocation_api.cache_lifetime: 24   # Hours

```

### Clearing the cache

[](#clearing-the-cache)

The cache should be cleaned periodically to comply with the Google terms of service (see below)

Run the following task:

```
$ php app/console google:geolocation:clean-cache

```

TODO
----

[](#todo)

- Explore use of Zend Caching layer instead of DB - Zend caching provides a SQLite option which would be useful for some projects.

Google Terms of Service
-----------------------

[](#google-terms-of-service)

Please respect the [terms of service](http://code.google.com/apis/maps/terms.html) (TOS) specified by Google for use of the Geocoding API.

The Geocoding API service must only be used in conjunction with a Google Map. The caching feature provided by the bundle is for temporary caching use in order to enhance the user experience when using Geocoding (This is permitted by the TOS). You should run the clean cache task periodically to clean up the cache values. The lifetime of each Geocoding result can be set via the paramater `google_geolocation.geolocation_api.cache_lifetime`. By default this is set to 24 hours

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 78.4% of commits — single point of failure

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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/289531?v=4)[Steve Lacey](/maintainers/stevelacey)[@stevelacey](https://github.com/stevelacey)

---

Top Contributors

[![dsyph3r](https://avatars.githubusercontent.com/u/262595?v=4)](https://github.com/dsyph3r "dsyph3r (29 commits)")[![jdeniau](https://avatars.githubusercontent.com/u/1398469?v=4)](https://github.com/jdeniau "jdeniau (2 commits)")[![dallegoet](https://avatars.githubusercontent.com/u/1019982?v=4)](https://github.com/dallegoet "dallegoet (1 commits)")[![dotlabel-chris](https://avatars.githubusercontent.com/u/956595?v=4)](https://github.com/dotlabel-chris "dotlabel-chris (1 commits)")[![hugomn](https://avatars.githubusercontent.com/u/497957?v=4)](https://github.com/hugomn "hugomn (1 commits)")[![b3nelof0n](https://avatars.githubusercontent.com/u/1371762?v=4)](https://github.com/b3nelof0n "b3nelof0n (1 commits)")[![plesiecki](https://avatars.githubusercontent.com/u/770675?v=4)](https://github.com/plesiecki "plesiecki (1 commits)")[![chrisixion](https://avatars.githubusercontent.com/u/1121888?v=4)](https://github.com/chrisixion "chrisixion (1 commits)")

### Embed Badge

![Health badge](/badges/dsyph3r-google-geolocation-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/dsyph3r-google-geolocation-bundle/health.svg)](https://phpackages.com/packages/dsyph3r-google-geolocation-bundle)
```

PHPackages © 2026

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