Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Nodiacritic Laravel Package

vria/nodiacritic

vria/nodiacritic is a PHP package for removing diacritics and accents from text, converting characters to plain ASCII equivalents. Useful for slugs, search normalization, sorting, and comparing user input in Laravel or any PHP project.

Deep Wiki
Context7

Getting Started

vria/nodiacritic is a single-purpose Twig extension: it registers a filter (typically named nodiacritic) that strips accents and diacritical marks from a string, e.g. Crème Brûlée → Creme Brulee. It is not a full transliteration library, so treat it as a normalization helper rather than an i18n solution.

Minimal setup:

composer require vria/nodiacritic

Where to look first:

  1. The package source — since this is a 2016 release with ~11 stars and no known repo link, read the extension class before trusting it. Confirm the exact filter name and whether it ships a Symfony bundle, a plain Twig\Extension\AbstractExtension (or the old Twig_Extension), or a service provider.
  2. Composer constraints — check composer.json for PHP and twig/twig version ranges. It predates Twig 2.x/3.x conventions, so expect Twig_Extension/Twig_SimpleFilter naming.
  3. The transliteration map — many such packages hardcode a PHP array of accented characters. Knowing what is covered (Latin-1? Latin Extended-A?) tells you where it will silently pass characters through.

Register it manually in standalone Twig:

$twig = new \Twig\Environment($loader);
$twig->addExtension(new \Vria\NoDiacritic\Twig\NoDiacriticExtension());

In Symfony, either add a bundle (if one exists in the package) or tag the extension as twig.extension in services.yaml. Verify the class name from the source; if the package only provides the filter callable, wrap it yourself.

First use case — slug generation for URLs:

<a href="/tag/{{ tag.name|nodiacritic|lower|replace({' ': '-'}) }}">{{ tag.name }}</a>

Implementation Patterns

Slugs and URL segments. The most common use is chaining nodiacritic with lower, whitespace replacement, and a preg_replace-style cleanup. Keep the slug pipeline in one Twig macro or one service so slugs stay consistent between templates, sitemaps, and redirects.

{% macro slug(value) %}
  {{ value|nodiacritic|lower|replace({' ': '-', '_': '-'})|replace({'/': '-'}) }}
{% endmacro %}

Search normalization. Normalize both the stored column and the search query with the same function so creme matches Crème. The filter only helps if applied symmetrically:

  • Store a separate name_normalized column populated on save (via a Doctrine listener or model event) rather than calling the filter at query time.
  • In the query builder, normalize the user input with the same PHP callable before comparison.
  • Do not rely on DB collation alone; it handles accents inconsistently across MySQL/SQLite/Postgres.

Sorting and grouping. Use the filter to build sort keys so Ångström sorts near Angstrom instead of after Z. Compute the key once when data is written; recomputing per row in Twig for large lists is wasteful.

Programmatic use outside Twig. If the package exposes the callable (often a static method or an invokable class), reuse it in console commands, imports, and form data transformers. If only the Twig filter is exposed, extract the underlying function into your own service so you have a single source of truth.

Forms and validation. Apply it in a PRE_SUBMIT listener or data transformer when you want accent-insensitive usernames or codes, but be explicit: users generally expect their display name to retain accents while an internal key is stripped. Keep the two fields separate.

Integration tip. In Symfony, register the extension as a service and tag it:

services:
    App\Twig\NoDiacriticExtension:
        tags: [twig.extension]

If the package ships its own bundle, enable it in bundles.php instead; do not do both.

Gotchas and Tips

This package is old and low-traffic. Last release was 2016, the repository is unknown, and it predates Twig 2/3 namespace changes and modern PHP. Before adopting, run a quick smoke test on your PHP version and check whether the class still loads under twig/twig ^2 or ^3. If the extension uses Twig_SimpleFilter, you may need a small compatibility shim or a vendored copy.

GPL-2.0 license. This is a copyleft license. Embedding it in a distributed proprietary product can create obligations. For internal-only apps it is usually fine, but confirm with your legal/OSS policy before shipping it in a commercial distribution. For many teams a 20-line normalization helper avoids the license question entirely.

It is not full transliteration. Expect the filter to handle composed Latin diacritics (á, ö, ñ, ç) but not necessarily:

  • Ligatures and special letters: ß, æ, ø, ł, đ, þ.
  • Decomposed Unicode (a + combining acute) unless the implementation normalizes first.
  • Non-Latin scripts — it will not romanize Cyrillic, Greek, or CJK.

Test your actual data, especially if names come from Eastern or Northern Europe.

Unicode normalization matters. Robust implementations use Normalizer::normalize(..., Normalizer::FORM_D) followed by a regex to strip combining marks, which requires the intl extension. If this package uses a hardcoded map instead, results are deterministic but incomplete. Either way, ensure ext-intl is installed if the code calls it — a missing extension becomes a fatal error in production.

Filter name and class name assumptions. Because the repository is not verifiable here, do not assume nodiacritic is the exact filter identifier or that the extension is auto-discovered. Grep the vendor directory:

grep -R "TwigFilter\|Twig_SimpleFilter\|getName" vendor/vria/nodiacritic

Cache clearing. After adding or changing a Twig extension in Symfony, clear the container cache (bin/console cache:clear). A missing filter at runtime is almost always a registration issue, not a package bug.

Performance. The filter is cheap per call but not free. Avoid invoking it inside loops over thousands of rows in a template. Precompute normalized columns or cache normalized values; this also keeps search behavior consistent.

Extension points and fallback. If the package lacks coverage you need, do not patch vendor/. Wrap it in your own Twig extension that calls the package first and then applies your extra character map (e.g. ß → ss). That keeps upgrades and license attribution clean and gives you one place to swap in symfony/string's AsciiSlugger or iconv('UTF-8', 'ASCII//TRANSLIT', ...) later.

Debugging tip. When a string comes out unchanged, check whether the character is precomposed or decomposed (use bin2hex/Normalizer::isNormalized). A filter that works on é but not on e + combining accent is a normalization gap, not a configuration problem.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
uni-method/symfony-lib
tacticmedia/scim-server-bundle
neika-ai/symfony-bundle
mattleads/agent-publishing-bundle
glavweb/framework-bundle
glavweb/extra-bundle
glavweb/api-bundle
glavweb/admin-bundle
adachsoft/api-version-bundle
elsayed85/laravel-api-exceptions
ouhssini/laravel-demo-mode
daworks/ncloud-outbound-mailer-driver
gp247/cms
ignibyte/aic-gates
nexa-merchant/blog
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
cgv/localized-resource