padam87/address-bundle

Symfony2 AddressBundle

Installs: 3 427

Dependents: 0

Stars: 7

Watchers: 2

Forks: 2

Language: PHP

v1.1.6 2014-08-19 11:27 UTC

README

Build Status Coverage Status Scrutinizer Quality Score SensioLabsInsight Latest Stable Version Total Downloads Latest Unstable Version License

1.1 Composer

"require": {
    ....
    "padam87/address-bundle": "~1.0"
},

1.2 BazingaGeocoderBundle

Install BazingaGeocoderBundle

1.3 AppKernel

// app/AppKernel.php
public function registerBundles()
{
    return array(
        // ...
        new Padam87\AddressBundle\Padam87AddressBundle(),
    );
}

1.4 doctrine:schema:update

Update Your schema

2, Usage

You can create a relation to one of the Entities, or you can use one of the traits.

2.1 Formatter

$formatted = $this->get("padam87.address.formatter")->format($address);

Flags

use Padam87\AddressBundle\Service\FormatterService;

...

$formatted = $this->get("padam87.address.formatter")->format($address, FormatterService::FLAG_NOBR);

Available flags

FLAG_NOBR No linebreak will be added

FLAG_HTML Outputs the address in html format

FLAG_NOCASE No case change will be applied

2.2 Twig extension

{{ address|address()|raw }}

This will output the formatted address, with the FLAG_HTML added by default

2.3 Geocoding

$address = new GeocodedAddress();

The listener will take care of the rest ;)