AddressBundle
AddressBundle copied to clipboard
:office: Formatted and geocoded addresses for Symfony
1, Installation
1.1 Composer
composer require padam87/address-bundle
1.2 AppKernel
// app/AppKernel.php
public function registerBundles()
{
return array(
// ...
new Padam87\AddressBundle\Padam87AddressBundle(),
);
}
2, Usage
Use the traits and embeddables with your schema.
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_NOBRNo linebreak will be addedFLAG_HTMLOutputs the address in html format
Extend / override templates
You can override or extend the language-specific formats. Just create the appropriate template under app\Resources\Padam87AddressBundle\views
example: app\Resources\Padam87AddressBundle\views\US.twig
contributing: Create a PR with your own country's format :)
2.2 Twig extension
{{ address|address()|raw }}
This will output the formatted address, with the FLAG_HTML added by default







