Guide
Slugger
Create lowercase ASCII URL slugs with curated, locale-aware transliteration maps.
Create a normalized URL slug
Slugger::slug() lowercases its output, discards unsupported characters, and normalizes whitespace, underscores, and repeated hyphens to one hyphen. The separator is always a hyphen; the API does not accept a custom separator.
<?php
use Lemonade\Framework\Support\Slug\Slugger;
$slugger = new Slugger();
$slug = $slugger->slug('Žluťoučký --- kůň!');
// zlutoucky-kun
Select a supported transliteration locale
The optional locale argument selects one of the curated transliteration maps. It is best-effort URL slug generation, not general Unicode transliteration. For example, the German map turns ä into ae.
$slugger->slug('Mädchen', locale: 'de');
// maedchen
Know the empty-result case
Unknown characters are discarded. Input containing no supported characters can therefore produce an empty slug. Output contains only lowercase ASCII letters, digits, and hyphens, without leading, trailing, or repeated hyphens.
$slugger->slug('___Hello___world___');
// hello-world
$slugger->slug('☆☆☆');
// ''