aferrandini/urlizer
Laravel-friendly URL slug generator that “urlizes” strings into clean, readable slugs with sensible transliteration and customization options. Ideal for turning titles or names into SEO-ready URLs consistently across your app.
Str::slug() alternatives) and PHP applications requiring deterministic URL normalization.strtolower, preg_replace, etc.autoload.php inclusion or custom PSR-4 setup.Illuminate\Support\Facades\Route syntax may break).| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| PHP Version Mismatch | High | Isolate in a service layer; use polyfills or fork. |
| Deprecated Features | Medium | Wrap in a compatibility layer (e.g., Str::of()->slug() fallback). |
| No Active Maintenance | Medium | Fork and modernize (e.g., add PHP 8.1+ support, Unicode improvements). |
| Edge-Case Slugs | Low | Supplement with custom validation (e.g., regex checks). |
Str::slug()?
cocur/slug-generator or spatie/slugifiable./post/hello-world vs. /post/hello-world-2)?spatie/sluggable) are incompatible.str_replace).Str::slug() vs. Urlizer).Post) with a feature flag."Café au Lait" → cafe-au-lait).composer require aferrandini/urlizer.config/app.php or create a custom helper:
// app/Helpers/SlugHelper.php
use Aferrandini\Urlizer\Urlizer;
function makeSlug(string $text): string {
return (new Urlizer())->urlize($text);
}
DB::statement).mb_strtolower).Route::get() references with Route::get() alternatives or wrap in a compatibility layer.Urlizer class directly:
require 'vendor/autoload.php';
$slug = (new \Aferrandini\Urlizer\Urlizer())->urlize("Hello World!");
Str::slug() overrides).spatie/sluggable or cocur/slug-generator if maintenance becomes untenable."Müller" → muller).Log::debug("Generated slug", ["input" => $text, "output" => $slug])).| Scenario | Impact | Mitigation |
|---|---|---|
| PHP Version Incompatibility | Build failures | Use a polyfill or fork. |
| Edge-Case Slugs | Broken URLs/SEO | Add validation (e.g., preg_match('/^[a-z0-9\-]+$/', $slug)). |
| Database Collisions | Duplicate slugs | Implement a counter suffix (e.g., -2). |
| Unicode Mismatch | Incorrect transliteration | Supplement with iconv or transliterator. |
$slug = Urlizer::urlize("Hello World!"); // "hello-world"
protected $rules in Urlizer.php).How can I help you explore Laravel packages today?