Slugify: Clean slugs in every language
Turn "مرحبا بالعالم", "Crème brûlée" or "XMLHttpRequest" into a clean URL slug with one Slugify::make() call. It keeps Unicode, or transliterates to ASCII when you ask.
Everything you need to build URL slugs
One static call for everyday use, plus a fluent builder when you need more control.
Unicode First
Arabic, Persian, Cyrillic, Greek, CJK and Indic scripts are kept as-is, with deterministic Unicode normalization.
ASCII on Request
Call ->ascii() for Latin-only slugs. A locale such as de or uk adds language-specific rules, but never forces ASCII.
Explicit Policies
Symbols, emoji and Unicode digits each follow a deliberate, configurable policy, with no invisible residue.
Smart Word Splitting
XMLHttpRequest becomes xml-http-request, and getUserID becomes get-user-id.
Any Separator
Use -, _, ., ~, an empty string, or your own. Repeats are collapsed automatically.
Replacement Rules
Add package-wide rules with Slugify::addRule(), or rules for one slug only with ->rule().
A quick look
Unicode by default, ASCII on demand, and a fluent builder when you need it.
1use Pharaonic\Slugify\Slugify; 2 3Slugify::make('Hello World'); // hello-world 4Slugify::make('مرحبا بالعالم'); // مرحبا-بالعالم 5Slugify::make('Crème brûlée', '-', true); // creme-brulee 6 7Slugify::of('Äpfel & Öl im XMLHttpRequest') 8 ->ascii('de') 9 ->rule('&', ' und ')10 ->maxLength(30)11 ->toString(); // aepfel-und-oel-im-xml-httpSlugify Questions
Quick answers about installing and using Slugify.
What is Slugify?
Framework-agnostic slug generation for PHP. Keep Unicode or transliterate to ASCII, use any separator, split camelCase and acronyms, and add your own replacement rules. It's a free, open-source PHP package by Pharaonic.
How do I install Slugify?
Run composer require pharaonic/php-slugify in your project's root directory.
What does Slugify require?
The latest release requires PHP 8.5+.
Does Slugify support Arabic and other non-Latin scripts?
Yes. By default, slugs keep Unicode letters, so مرحبا بالعالم becomes مرحبا-بالعالم. Pass true as the third argument to Slugify::make() to transliterate to ASCII instead.
Does it depend on Laravel or another framework?
No. Slugify is plain PHP with no framework, container or config files. For Eloquent models, use the companion package pharaonic/laravel-sluggable.
How do I customize how characters are replaced?
Add package-wide rules with Slugify::addRule('&', ' and '), or rules for one slug only with Slugify::of($title)->rule('&', ' and ').
Is Slugify free to use?
Yes. Slugify is open source under the MIT license, so you can use it in personal and commercial projects.
Where can I find the Slugify documentation?
Read the Slugify documentation for setup and usage examples.
How do I report a bug or contribute to Slugify?
Open an issue or a pull request on GitHub, or ask in the Pharaonic Discord.
Ready to dig in?
Read the full documentation for installation, Unicode and ASCII slugs, separators, replacement rules, the fluent API, and custom transliterators.