EasySlug is very simple class to making slug from base text.
Using Composer, just require the pyton/easyslug package:
{
"require": {
"pyton/easyslug": "~1.0"
}
}
$easySlug = new EasySlug();
$string = 'Base Slug string.';
$slug = $easySlug->create($string);
echo $slug->plain() . PHP_EOL;
// base-slug-string
echo $slug->format('%s.html') . PHP_EOL;
// base-slug-string.html
$easySlug->setReplacement('_');
$slug = $easySlug->create($string);
echo $slug->plain() . PHP_EOL;
// base_slug_string
echo $slug->format('%s.html') . PHP_EOL;
// base_slug_string.html