Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nash-ye/nslug
Yet another unicode slug generator library.
https://github.com/nash-ye/nslug
php php-library
Last synced: about 8 hours ago
JSON representation
Yet another unicode slug generator library.
- Host: GitHub
- URL: https://github.com/nash-ye/nslug
- Owner: nash-ye
- License: gpl-3.0
- Created: 2016-10-16T13:20:32.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2016-10-16T22:02:00.000Z (about 8 years ago)
- Last Synced: 2024-04-09T20:21:38.533Z (7 months ago)
- Topics: php, php-library
- Language: PHP
- Homepage:
- Size: 18.6 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# nSlug
[![Latest Stable Version](https://poser.pugx.org/nash-ye/nslug/v/stable)](https://packagist.org/packages/nash-ye/nslug)
[![Total Downloads](https://poser.pugx.org/nash-ye/nslug/downloads)](https://packagist.org/packages/nash-ye/nslug)
[![License](https://poser.pugx.org/nash-ye/nslug/license)](https://packagist.org/packages/nash-ye/nslug)Yet another unicode slug generator library.
## Usage
```php
use NSlug\SlugGenerator;$options = [
'limit' => null,
'delimiter' => '-',
'lowercase' => true,
];$slugGenerator = new SlugGenerator($options);
// English strings.
echo $slugGenerator->generate('Hello World'); // Prints 'hello-world'.
echo $slugGenerator->generate('Life is too short!'); // Prints 'life-is-too-short'.// Arabic strings.
echo $slugGenerator->generate('صباح جميل'); // Prints 'صباح-جميل'.
echo $slugGenerator->generate('مساء الخير'); // Prints 'مساء-الخير'.
```## Options
- `limit` int|null The characters limit to truncate, default `null`.
- `delimiter` string The delimiter, default `-`.
- `lowercase` bool Convert to lower-case?, default `true`.## Installation
The supported way of installing nSlug is via Composer.
```sh
$ composer require nash-ye/nslug
```## Requirements
nSlug requires PHP 5.5+.