Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sunrise-php/slugger
Simple slugger for PHP 7.1+ based on ICU
https://github.com/sunrise-php/slugger
icu latin php-library php7 php8 slug slugger slugify translit transliterate transliteration transliterator
Last synced: 4 days ago
JSON representation
Simple slugger for PHP 7.1+ based on ICU
- Host: GitHub
- URL: https://github.com/sunrise-php/slugger
- Owner: sunrise-php
- License: mit
- Created: 2018-10-23T17:08:19.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-04-24T07:22:34.000Z (7 months ago)
- Last Synced: 2024-06-06T12:52:07.896Z (5 months ago)
- Topics: icu, latin, php-library, php7, php8, slug, slugger, slugify, translit, transliterate, transliteration, transliterator
- Language: PHP
- Homepage:
- Size: 47.9 KB
- Stars: 10
- Watchers: 4
- Forks: 4
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Simple slugger for PHP 7.1+ based on ICU
[![Gitter](https://badges.gitter.im/sunrise-php/support.png)](https://gitter.im/sunrise-php/support)
[![Build Status](https://circleci.com/gh/sunrise-php/slugger.svg?style=shield)](https://circleci.com/gh/sunrise-php/slugger)
[![Code Coverage](https://scrutinizer-ci.com/g/sunrise-php/slugger/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/sunrise-php/slugger/?branch=master)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/sunrise-php/slugger/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/sunrise-php/slugger/?branch=master)
[![Total Downloads](https://poser.pugx.org/sunrise/slugger/downloads?format=flat)](https://packagist.org/packages/sunrise/slugger)
[![Latest Stable Version](https://poser.pugx.org/sunrise/slugger/v/stable?format=flat)](https://packagist.org/packages/sunrise/slugger)
[![License](https://poser.pugx.org/sunrise/slugger/license?format=flat)](https://packagist.org/packages/sunrise/slugger)## Installation
```bash
composer require sunrise/slugger
```## How to use
#### Russian to Latin (default)
```php
use Sunrise\Slugger\Slugger;$slugger = new Slugger();
// syesh-yeshche-etikh-myagkikh-frantsuzskikh-bulok-da-vypey-chayu
$slugger->slugify('Съешь ещё этих мягких французских булок, да выпей чаю');
```#### Deutsch to Latin
```php
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
```php
$slugger = new Slugger(null, [
'.' => ' dot ',
'@' => ' at ',
]);// [email protected]
$slugger->slugify('admin-at-acme-dot-com');
```## Useful links
* http://site.icu-project.org/
* http://userguide.icu-project.org/transforms/general
* http://demo.icu-project.org/icu-bin/translit