PHP Classes

PHP Slugify: Create a slug text from a given text string

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 107 All time: 9,684 This week: 673Up
Version License PHP version Categories
php-slugify 1.0.0MIT/X Consortium ...5PHP 5, Text processing
Description 

Author

This class can be used to create a slug text from a given text string.

It can take a given string encoded in UTF-8 and then can replace non-ASCII characters by equivalent strings that only use ASCII text.

The class uses an internal array that is used to defined how the characters are mapped. It also provides a function that can be used to change the mappings of specific characters.

Innovation Award
PHP Programming Innovation award nominee
April 2021
Number 6
A slug is a text that is often used in URLs to make them more readable for the users.

Usually this is done by replacing any non-ASCII characters by equivalent characters that can be read by users in the way the characters should sound.

There are many solutions to create a slug text. This package provides a more flexible solution that allows developers to customize how each character is mapped to other characters in the slug text.

This solution may be better when applications need to create slug texts that need to be readable by users that only understand other languages besides English.

Manuel Lemos
Picture of Moamen Eltouny
  Performance   Level  
Name: Moamen Eltouny <contact>
Classes: 38 packages by
Country: Egypt Egypt
Age: 31
All time rank: 257626 in Egypt Egypt
Week rank: 206 Up3 in Egypt Egypt Up
Innovation award
Innovation award
Nominee: 22x

Documentation

<p align="center"><a href="https://pharaonic.io" target="_blank"><img src="https://raw.githubusercontent.com/Pharaonic/logos/main/php/slugify.jpg" width="470"></a></p>

<p align="center"> <a href="https://github.com/Pharaonic/php-slugify" target="_blank"><img src="http://img.shields.io/badge/source-pharaonic/php--slugify-blue.svg?style=flat-square" alt="Source"></a> <a href="https://packagist.org/packages/pharaonic/php-slugify" target="_blank"><img src="https://img.shields.io/packagist/v/pharaonic/php-slugify?style=flat-square" alt="Packagist Version"></a> <img src="https://img.shields.io/packagist/dt/pharaonic/php-slugify?style=flat-square" alt="Packagist Downloads"> <img src="http://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square" alt="Source"> </p>

<h1 align="center">Simplest Slugify for PHP.</h1>

Install

Slugify requires the Multibyte String mbstring extension from PHP.<br> Install the latest version using Composer:

$ composer require pharaonic/php-slugify

Usage

<a name="GS"></a>

Get Slug

use Pharaonic\Slugify\Slugify;
echo Slugify::get('Moamen Eltouny');

// OR
echo slug('Moamen Eltouny');

<a name="RM"></a>

Rules Manipulation

use Pharaonic\Slugify\Slugify;
Slugify::rule('ö', 'oe');

License

MIT license


  Files folder image Files (5)  
File Role Description
Files folder imagesrc (2 files)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files (5)  /  src  
File Role Description
  Accessible without login Plain text file Helpers.php Aux. Auxiliary script
  Plain text file Slugify.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:107
This week:0
All time:9,684
This week:673Up
User Comments (1)
Congratulations, thats a very good class ;-)
3 years ago (José Filipe Lopes Santos)
70%StarStarStarStar