Skip to content

nash-ye/nslug

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nSlug

Latest Stable Version Total Downloads License

Yet another unicode slug generator library.

Usage

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.

$ composer require nash-ye/nslug

Requirements

nSlug requires PHP 5.5+.