Skip to content

sunrise-php/slugger

Repository files navigation

Simple slugger for PHP 7.1+ based on ICU

Gitter Build Status Code Coverage Scrutinizer Code Quality Total Downloads Latest Stable Version License

Installation

composer require sunrise/slugger

How to use

Russian to Latin (default)

use Sunrise\Slugger\Slugger;

$slugger = new Slugger();

// syesh-yeshche-etikh-myagkikh-frantsuzskikh-bulok-da-vypey-chayu
$slugger->slugify('Съешь ещё этих мягких французских булок, да выпей чаю');

Deutsch to Latin

use Sunrise\Slugger\Slugger;

$slugger = new Slugger('de-ASCII');

// falsches-ueben-von-xylophonmusik-quaelt-jeden-groesseren-zwerg
$slugger->slugify('Falsches Üben von Xylophonmusik quält jeden größeren Zwerg');

Custom replacements

$slugger = new Slugger(null, [
    '.' => ' dot ',
    '@' => ' at ',
]);

// admin@acme.com
$slugger->slugify('admin-at-acme-dot-com');

Useful links