PHPackages                             malenki/slug - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. malenki/slug

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

malenki/slug
============

Simple class to create slug.

1.0.0(12y ago)11.3k↓50%MITPHPPHP &gt;=5.3.0

Since Apr 26Pushed 10y ago1 watchersCompare

[ Source](https://github.com/malenkiki/slug)[ Packagist](https://packagist.org/packages/malenki/slug)[ Docs](https://github.com/malenkiki/slug)[ RSS](/packages/malenki-slug/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

slug
====

[](#slug)

Slug creator, with history and language transliteration.

How to install it
-----------------

[](#how-to-install-it)

You can clone this repository or use [composer](https://getcomposer.org/):

```
{
    "require": {
        "malenki/slug": "dev-master",
    }
}
```

Requirements
------------

[](#requirements)

You must have [Intl PHP extension](http://www.php.net/intl) and [mbstring PHP extension](http://www.php.net/mbstring).

How to use it
-------------

[](#how-to-use-it)

### Basic usage

[](#basic-usage)

Very simple:

```
use \Malenki\Slug;

$s = new Slug('Some string!');

echo $s->render();
//or
echo $s; // toString available, give "some-string"
```

### Add custom rules

[](#add-custom-rules)

You can add your own rules to replace some chars:

```
use \Malenki\Slug;

$s = new Slug('One example string, again!');

$s->rule('!', '-wouah');

echo $s; // "one-example-string-again-wouah"
```

You can define void slug object to use many string later, usefull if you define rules, to use them again and again:

```
use \Malenki\Slug;

$s = new Slug();

$s->rule('!', '-wouah')->rule('?', '-huh');
$s->v('Genius!');
echo $s; // "genius-wouah"
$s->v('Genius?');
echo $s; // "genius-huh"
```

### History

[](#history)

By default, Slug use history into running script context, if a generated slug is already present, then add number with increment to it:

```
use \Malenki\Slug;

$s = new Slug('one-string');
echo $s; // "one-string"
$s = new Slug('one-string');
echo $s; // "one-string-2"
$s = new Slug('one-string');
echo $s; // "one-string-3"
```

But you can disable this behaviour:

```
use \Malenki\Slug;

$s = new Slug('one-string');
echo $s->noHistory(); // "one-string"
$s = new Slug('one-string');
echo $s->noHistory(); // "one-string"
$s = new Slug('one-string');
echo $s->noHistory(); // "one-string"

// or

$s = new Slug();
echo $s->noHistory()->v('one-string'); // "one-string"
echo $s->noHistory()->v('one-string'); // "one-string"
echo $s->noHistory()->v('one-string'); // "one-string"
```

You can use predefined history of slug too, usefull if you have a lot of them in DB for example:

```
$s = new Slug();
Slug::history(array('one-string', 'another-one'));
echo $s->v('one-string'); // "one-string-2"
```

### Non-ASCII characters

[](#non-ascii-characters)

Use other language than english is possible too:

```
// some french
$s = new Slug('C’est rigolo d’écrire en français !');
echo $s; // "c-est-rigolo-d-ecrire-en-francais"

// some greek
$s = new Slug('Τα ελληνικά σου είναι καλύτερα απο τα Γαλλικά μου!');
echo $s; // "ta-ellenika-sou-einai-kalytera-apo-ta-gallika-mou"
```

So, enjoy!

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

4405d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6af62130bd16d4e6bbaa5877829b6377386ef9fb6593592052dbb6eeb87c4a02?d=identicon)[malenki](/maintainers/malenki)

---

Top Contributors

[![malenkiki](https://avatars.githubusercontent.com/u/195776?v=4)](https://github.com/malenkiki "malenkiki (25 commits)")

---

Tags

urlslugstring

### Embed Badge

![Health badge](/badges/malenki-slug/health.svg)

```
[![Health](https://phpackages.com/badges/malenki-slug/health.svg)](https://phpackages.com/packages/malenki-slug)
```

###  Alternatives

[jbroadway/urlify

A fast PHP slug generator and transliteration library that converts non-ascii characters for use in URLs.

6737.4M62](/packages/jbroadway-urlify)[spomky-labs/base64url

Base 64 URL Safe Encoding/Decoding PHP Library

15439.5M49](/packages/spomky-labs-base64url)[pid/speakingurl

Generate of so called 'static' or 'Clean URL' or 'Pretty URL' or 'nice-looking URL' or 'Speaking URL' or 'user-friendly URL' or 'SEO-friendly URL' or 'slug' from a string.

1.1k5.3k1](/packages/pid-speakingurl)[voku/urlify

PHP port of URLify.js from the Django project. Transliterates non-ascii characters for use in URLs.

254.1M7](/packages/voku-urlify)[keyvanakbary/slugifier

A full-featured, simple, clean and pure functional implementation for creating slugs

68187.9k4](/packages/keyvanakbary-slugifier)[wazum/sluggi

TYPO3 extension for URL slug management with inline editing, auto-sync, locking, access control, and redirects

39488.5k](/packages/wazum-sluggi)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
