phil / url-bundle
phil/url in Symfony: a form field that detects the kind of a web address among accepted enum sets, the constraint UrlOfType, the column type phil_url, and addresses in Twig
Package info
github.com/parler-haut-interagir-librement/url-bundle
Type:symfony-bundle
pkg:composer/phil/url-bundle
Requires
- php: >=8.5
- phil/enums: ^0.3@dev
- phil/url: ^0.1@dev
- symfony/config: ^8.2
- symfony/dependency-injection: ^8.2
- symfony/form: ^8.2
- symfony/options-resolver: ^8.2
- symfony/validator: ^8.2
Requires (Dev)
- ext-intl: *
- doctrine/dbal: ^4.5
- doctrine/doctrine-bundle: ^3.3
- doctrine/orm: ^3.7
- phpunit/phpunit: ^13.4
- psr/log: ^3.0
- symfony/event-dispatcher: ^8.2
- symfony/framework-bundle: ^8.2
- symfony/http-kernel: ^8.2
- symfony/translation: ^8.2
- symfony/twig-bridge: ^8.2
- symfony/twig-bundle: ^8.2
- twig/twig: ^3.21
Suggests
- doctrine/dbal: For the phil_url column type
- twig/twig: For url_display, url_type and url_type_label
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-11 13:33:23 UTC
README
Link fields that detect their kind, a validation constraint, a column type and Twig filters.
phil/url-bundle brings phil/url into a Symfony application. TypedUrlType is one text field that reads an
address, https by default, and detects its kind among the enum sets it accepts, giving a TypedUrl. The constraint
UrlOfType checks that a text, a Url or a TypedUrl is of an accepted kind. With DoctrineBundle, the column type
phil_url keeps a normalised Url in a VARCHAR(2048). Twig gets url_display, url_type() and url_type_label.
Messages come in English and French.
It is for Symfony applications whose forms collect links: a social profile, a shop's website, an organisation's page
in a registry. A field or a constraint accepts the international kinds of KnownUrlType, the application's own
enums, or both, named as an enum class, a case, an EnumSet or a list of these. An address and its kind are stored
as two columns the application maps itself, the kind with its own enum.
Use phil/url directly outside Symfony or inside a domain model. The bundle adds no rule of its own: normalisation,
kinds and detection come from the library, and the bundle wires them into Symfony Form, Validator, Doctrine DBAL and
Twig.
Status
| Part | State |
|---|---|
TypedUrlType: one text field, the kind detected |
Implemented and tested |
UrlOfType: a text, a Url or a TypedUrl of an accepted kind |
Implemented and tested |
The column type phil_url, optional |
Implemented and tested |
Twig: url_display, url_type(), url_type_label |
Implemented and tested |
| Messages in English and French | Implemented and tested |
Documentation
| Document | What it covers |
|---|---|
| Installation | Requirements, installing, registering. |
| Accepted kinds | How a field or a constraint names the kinds it accepts, the application's own included. |
| Forms | TypedUrlType. |
| Validation | UrlOfType. |
| Doctrine | The column type phil_url, and keeping an address with its kind. |
| Twig | url_display, url_type(), url_type_label. |
| 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/url-bundle
$builder->add('instagram', TypedUrlType::class, ['types' => KnownUrlType::Instagram, 'required' => false]); #[UrlOfType([KnownUrlType::Facebook, KnownUrlType::Instagram])] public ?string $social = null;
Requirements
PHP 8.5 or later; phil/url 0.1 and phil/enums 0.3; symfony/config, symfony/dependency-injection,
symfony/form, symfony/options-resolver and symfony/validator 8.2 or later. Doctrine DBAL 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.