phil / typography-bundle
phil/typography in Symfony: one typographer per locale from configuration, the typography and typography_text Twig filters, and typographic fixes on the HTML that phil/ujo renders
Package info
github.com/parler-haut-interagir-librement/typography-bundle
Type:symfony-bundle
pkg:composer/phil/typography-bundle
Requires
- php: >=8.5
- phil/typography: ^0.1@dev
- symfony/config: ^8.2
- symfony/dependency-injection: ^8.2
- symfony/translation-contracts: ^3.6
Requires (Dev)
- phil/ujo: ^0.1@dev
- phil/ujo-bundle: ^0.1@dev
- phpunit/phpunit: ^13.4
- psr/log: ^3.0
- symfony/event-dispatcher: ^8.2
- symfony/form: ^8.2
- symfony/framework-bundle: ^8.2
- symfony/http-kernel: ^8.2
- symfony/options-resolver: ^8.2
- symfony/translation: ^8.2
- symfony/twig-bridge: ^8.2
- symfony/twig-bundle: ^8.2
- symfony/validator: ^8.2
- twig/twig: ^3.21
Suggests
- phil/ujo-bundle: For typographic fixes on the HTML of UJO documents
- symfony/translation: For the filters in the locale of the request, through its LocaleSwitcher
- twig/twig: For the typography and typography_text filters
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-11 06:17:21 UTC
README
Typographic quotes, dashes, French spaces and soft hyphens everywhere a Symfony application prints text.
phil/typography-bundle puts phil/typography in a Symfony application. It builds one typographer per locale from the
configuration — the preset of the locale, or the fixers the application lists —, registers each configured locale as
a service of its own, adds the typography and typography_text Twig filters, and, when phil/ujo-bundle is
installed, runs the typographer on the HTML of every UJO document the application renders — each in the locale of the
request, unless a template names another.
It is for any Symfony application that shows text written by people: a CMS, a blog, a forum, a shop. A template
writes {{ article.body|typography }}; the UJO documents rendered by ujo_html or Ujo::toHtml() come out with
their typography fixed and nothing to write.
It is a thin bundle built on symfony/config and symfony/dependency-injection. Twig and
phil/ujo-bundle are optional: the filters are registered only when Twig is installed, and the UJO integration only
when that bundle's renderer is in the container.
The design is small: PhilTypographyBundle reads the configuration, TypographyServices registers the services,
TypographyExtension holds the filters, TypographyHtmlFilter and UjoFilterPass decorate the UJO renderer.
Status
| Part | State |
|---|---|
| Configuration: default locale, hyphenation and its experimental languages, protected elements, fixers by locale | Implemented and tested |
Typographers, Typographer and one service per configured locale, injectable by argument name |
Implemented and tested |
Twig: typography for HTML, escaping what is not marked safe; typography_text for plain text |
Implemented and tested |
The locale of the request, through Symfony's LocaleSwitcher, for the filters and the UJO pass |
Implemented and tested |
Typography on the HTML of UJO documents, through phil/ujo-bundle's renderer |
Implemented and tested |
Documentation
| Document | What it covers |
|---|---|
| Installation | Requirements, installing and enabling the bundle. |
| Configuration | Every option, and the services it gives. |
| Twig | The two filters, escaping, and the locale of a template. |
| UJO documents | The typographic pass over the HTML of UJO documents. |
| Exceptions | What the bundle and the library throw. |
| Extension points | What an application implements, configures, replaces or relies on. |
| Testing | The bundle's tests, and testing an application that uses it. |
| Reference | Every class and service of the bundle. |
Quick start
composer require phil/typography-bundle
# config/packages/phil_typography.yaml phil_typography: default_locale: fr_CA locales: en_GB: [] # a service with the preset of en_GB
<h1>{{ article.title|typography_text }}</h1> {{ article.bodyHtml|raw|typography }} <aside lang="en-GB">{{ article.quote|typography('en_GB') }}</aside>
Requirements
PHP 8.5 or later, Symfony 8.2 and phil/typography. Twig 3.21, for the filters; symfony/translation, for the
locale of the request; phil/ujo-bundle, for the UJO integration.
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.