Search by

phil / address-bundle

phil

phil/address in Symfony: an address form whose fields follow the country chosen, live through a Stimulus controller, the constraint ValidAddress, the JSON column type phil_address, and addresses in Twig

Package info

github.com/parler-haut-interagir-librement/address-bundle

Homepage

Type:symfony-bundle

pkg:composer/phil/address-bundle

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

0.1.0-alpha 2026-11-11 06:11 UTC

This package is auto-updated.

Last update: 2026-11-11 13:29:22 UTC


README

An address form for Symfony whose fields follow the country the person picks.

phil/address-bundle brings the addresses of phil/address into Symfony. AddressType shows the fields of the chosen country's format, in its order, named as it names them and required as it requires them. Where the country has states or provinces, the administrative area is a choice of them. When the country changes, a Stimulus controller reads the bundle's format endpoint and shows, hides and relabels the fields in the browser. On submission, the address is checked against its country and each wrong field gets its own error. The bundle also gives the constraint ValidAddress, the Doctrine column type phil_address for one JSON column, the Twig filters address, address_lines and address_label, and the Twig functions country_name and address_schema. Labels and messages are in English and French.

It is for Symfony applications where a customer, a member or an editor types an address that may be in any country, and where pages or postal labels show it back. Options limit the countries offered and add the recipient's names.

Outside Symfony, use phil/address on its own. The bundle keeps the rules in the library. The form and the constraint ask its validator, the endpoint reads its formats, the column type uses AddressArray, and Twig its formatter.

Status

Part State
AddressType: fields of the country, states as choices, errors per field Implemented and tested
The format endpoint and the Stimulus controller address Implemented and tested
ValidAddress, the column type phil_address Implemented and tested
Twig: address, address_lines, address_label, country_name, address_schema Implemented and tested

Documentation

Document What it covers
Installation Requirements, registering, configuration, the route.
Forms AddressType, its options, and its Stimulus controller.
Validation and storage ValidAddress and phil_address.
Twig The filters and the functions.
Extension points What an application implements, configures, replaces or relies on.
Testing How the bundle is tested.
Reference Every type of the bundle.

Quick start

composer require phil/address-bundle
phil_address:
    default_country: CA
    format_url: /address-format/__COUNTRY__
$builder->add('address', AddressType::class);
{{ shop.address|address|nl2br }}

Requirements

PHP 8.5 or later with ext-intl; phil/address 0.1; Symfony 8.2's config, dependency injection, form, HTTP foundation, Intl, options resolver and validator, and the translation contracts. Doctrine DBAL, the router and Twig are optional.

Contributing

Contributions are welcome on the PHIL monorepo: read the contribution guide and the code of conduct. Report a vulnerability privately, as the security policy explains, never in a public issue.

License

MIT, © Philippe Gamache, doing business as Le Gnome Archiviste; a Parler Haut Interagir Librement project. See LICENSE.