padam87 / address-bundle
Symfony2 AddressBundle
Installs: 13 176
Dependents: 0
Suggesters: 0
Security: 0
Stars: 10
Watchers: 2
Forks: 6
Open Issues: 2
Type:symfony-bundle
Requires
- php: ~5.5|~7.0
- doctrine/doctrine-bundle: ~1.6
- doctrine/orm: ~2.5
- symfony/symfony: ~2.8|~3.0
- twig/twig: ~1.0
Requires (Dev)
- phpunit/phpunit: ~4.8
README
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_NOBR
No linebreak will be addedFLAG_HTML
Outputs 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