PHPackages                             ballen/sluginator - 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. ballen/sluginator

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

ballen/sluginator
=================

A simple URL slug creation library for PHP, simply feed it a string (such as a blog title) and it will create a URL friendly slug.

2.0.3(3y ago)3404[1 PRs](https://github.com/allebb/sluginator/pulls)MITPHPPHP ^7.3.0|^8.0.0CI failing

Since Nov 23Pushed 3mo ago2 watchersCompare

[ Source](https://github.com/allebb/sluginator)[ Packagist](https://packagist.org/packages/ballen/sluginator)[ RSS](/packages/ballen-sluginator/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (8)Dependencies (1)Versions (10)Used By (0)

Sluginator
==========

[](#sluginator)

[![Build](https://github.com/allebb/sluginator/workflows/build/badge.svg)](https://github.com/allebb/sluginator/actions)[![Code Coverage](https://camo.githubusercontent.com/91fe7d2c539abcb4919bc98f4249af8d965f697c8d546ebc09d6b674b23c2347/68747470733a2f2f636f6465636f762e696f2f67682f616c6c6562622f736c7567696e61746f722f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/allebb/sluginator)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/77f6aa6c5a0dd436475658402f711d5cd3fa9d9a9256ec94c51ea7ac4cce6095/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f616c6c6562622f736c7567696e61746f722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/allebb/sluginator/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/e83c3947486d695d16936f160fe2b9a12456eb50797457f7407f53ea8e8bd3c7/68747470733a2f2f706f7365722e707567782e6f72672f62616c6c656e2f736c7567696e61746f722f762f737461626c65)](https://packagist.org/packages/ballen/sluginator)[![Latest Unstable Version](https://camo.githubusercontent.com/1430968dddf5dc1bb68cf9e7f60edc419511d32549ee6d02bb4e5610b7e034c2/68747470733a2f2f706f7365722e707567782e6f72672f62616c6c656e2f736c7567696e61746f722f762f756e737461626c65)](https://packagist.org/packages/ballen/sluginator)[![License](https://camo.githubusercontent.com/f62e6fcc439034abb3782ac81228e92e6b74097953d2b19afa9e86b63931714c/68747470733a2f2f706f7365722e707567782e6f72672f62616c6c656e2f736c7567696e61746f722f6c6963656e7365)](https://packagist.org/packages/ballen/sluginator)

A URL slug creation and sanitisation library for PHP, simply feed it a string (such as a blog title) and it will create a URL friendly slug.

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

[](#requirements)

This library is unit tested against PHP 7.3, 7.4, 8.0, 8.1 and 8.2!

If you need to use an older version of PHP, you should instead install the 2.x version of this library (see below for details).

License
-------

[](#license)

This client library is released under the MIT license, a [copy of the license](LICENSE) is provided in this package.

Setup
-----

[](#setup)

I highly recommend the use of [Composer](https://getcomposer.org/) when installing and using this library, it is not mandatory however and you can use a provided 'include' script to load in this library if required.

### Composer

[](#composer)

Add the latest version of Sluginator to your project by running:

```
composer require ballen/sluginator

```

**If you need to use an older version of PHP, version 1.x.x supports PHP 5.6, 7.0, 7.1 and 7.2, you can install this version using Composer with this command instead:**

```
composer require ballen/sluginator ^1.0
```

### Standalone

[](#standalone)

You can use the library "standalone" by downloading it from the [GitHub releases section](https://github.com/allebb/sluginator/releases), extracting the files to a place on your server and then adding the "include" into your code like so:

```
require_once 'path/to/Sluginator/lib/Slug.php';
```

Examples
--------

[](#examples)

```
use Ballen\Sluginator\Slug;

$slug = new Slug('My awesomely *wickid* example title!!!');

echo $slug;
```

The output will be `my-awesomely-wickid-example-title`.

The library also contains other useful methods to enable you to:

- Specify characters of which should be removed from the string, by default a healthy set of non-url characters are removed.
- Specify a different space replacement character (by default this is a hyphen '-').
- Output the slug with or without URL encoding (disabled by default as not required).
- Force output as all lowercase character (default is 'true').

Here is an example using a few extra settings:

```
use Ballen\Sluginator\Slug;

$slug = new Slug('My awesomely *wickid* example title!!!');

$slug->setUseLowercase(false)->setSpaceCharacter('_')->build();

echo $slug->getSlug();
```

In the above example we have request that the slug character case remains untouched and instead of splitting spaces with a hyphen (-) we will instead replace them with underscore characters (\_) instead.

Tests and coverage
------------------

[](#tests-and-coverage)

This library is fully unit tested using [PHPUnit](https://phpunit.de/).

I use GitHub Actions for continuous integration, which triggers the unit tests each time a commit is pushed.

If you wish to run the tests yourself you should run the following:

```
# Install the Sluginator Library with the 'development' packages this then including PHPUnit!
composer install

# Now we run the unit tests (from the root of the project) like so:
./vendor/bin/phpunit

```

Code coverage can also be ran but requires XDebug installed...

```
./vendor/bin/phpunit --coverage-html ./report

```

Support
-------

[](#support)

I am happy to provide support via. my personal email address, so if you need a hand drop me an email at: ballen@bobbyallen.me.

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance54

Moderate activity, may be stable

Popularity16

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 92% 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

Every ~422 days

Recently: every ~265 days

Total

8

Last Release

1235d ago

Major Versions

1.0.3 → 2.0.02020-12-23

PHP version history (4 changes)1.0.0PHP &gt;=5.4.0

1.0.1PHP &gt;=5.3.0

2.0.0PHP &gt;=7.3.0

2.0.2PHP ^7.3.0|^8.0.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/4729a376aa8281d9456a90c000e991aa605c96f15251469acd5a7a5c6cdde2e6?d=identicon)[allebb](/maintainers/allebb)

---

Top Contributors

[![allebb](https://avatars.githubusercontent.com/u/767628?v=4)](https://github.com/allebb "allebb (23 commits)")[![KDA809](https://avatars.githubusercontent.com/u/19858208?v=4)](https://github.com/KDA809 "KDA809 (2 commits)")

---

Tags

urlslugfriendly

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ballen-sluginator/health.svg)

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

###  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)[spatie/url

Parse, build and manipulate URL's

73914.3M97](/packages/spatie-url)[league/uri-components

URI components manipulation library

31932.3M67](/packages/league-uri-components)[sabre/uri

Functions for making sense out of URIs.

29335.2M40](/packages/sabre-uri)[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)

PHPackages © 2026

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