sunrise/slugger

Slugger for PHP 7.1+ based on ICU

v2.1.3 2022-04-19 19:39 UTC

README

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