PHPackages                             muffin/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. [Database &amp; ORM](/categories/database)
4. /
5. muffin/slug

ActiveCakephp-plugin[Database &amp; ORM](/categories/database)

muffin/slug
===========

Slugging support for CakePHP ORM

3.0.0(2y ago)38278.1k↓65.3%14[4 issues](https://github.com/UseMuffin/Slug/issues)[1 PRs](https://github.com/UseMuffin/Slug/pulls)5MITPHPCI failing

Since Jan 5Pushed 1y ago4 watchersCompare

[ Source](https://github.com/UseMuffin/Slug)[ Packagist](https://packagist.org/packages/muffin/slug)[ Docs](https://github.com/usemuffin/slug)[ RSS](/packages/muffin-slug/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (4)Versions (16)Used By (5)

Slug
====

[](#slug)

[![Build Status](https://camo.githubusercontent.com/fd8a322cb3089f9d9164d8a78d69374bed2a4bc47bf13e47cc493c68a1c07c05/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f5573654d756666696e2f536c75672f63692e796d6c3f7374796c653d666c61742d737175617265)](https://github.com/UseMuffin/Slug/actions)[![Coverage](https://camo.githubusercontent.com/69ea2fec35999243fd63dd743b323709ea9be05700d752ffb8c092cd1df231fb/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f5573654d756666696e2f536c75672f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://codecov.io/github/UseMuffin/Slug)[![Total Downloads](https://camo.githubusercontent.com/5a29d063d9c7ab214c13ea9b64aaa758b75289793507861d89c6dd0bb4b3cbc8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d756666696e2f736c75672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/muffin/slug)[![License](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](LICENSE)

Slugging for CakePHP

Installation
------------

[](#installation)

Using [Composer](http://getcomposer.org):

```
composer require muffin/slug
```

Load the plugin using the CLI command:

```
./bin/cake plugin load Muffin/Slug
```

Usage
-----

[](#usage)

To enable slugging add the behavior to your table classes in the `initialize()` method.

```
public function initialize(array $config): void
{
    //etc
    $this->addBehavior('Muffin/Slug.Slug', [
        // Optionally define your custom options here (see Configuration)
    ]);
}
```

> Please note that Slug expects a database column named `slug` to function. If you prefer to use another column make sure to specify the `field`configuration option.

### Searching

[](#searching)

If you want to find a record using its slug, a custom finder is provided by the plugin.

```
// src/Controller/ExamplesController.php
$example = $this->Examples->find('slugged', slug: $slug);
```

Configuration
-------------

[](#configuration)

Slug comes with the following configuration options:

- `field`: name of the field (column) to hold the slug. Defaults to `slug`.
- `displayField`: name of the field(s) to build the slug from. Defaults to the `\Cake\ORM\Table::displayField()`.
- `separator`: defaults to `-`.
- `replacements`: hash of characters (or strings) to custom replace before generating the slug.
- `maxLength`: maximum length of a slug. Defaults to the field's limit as defined in the schema (when possible). Otherwise, no limit.
- `slugger`: class that implements the `Muffin\Slug\SlugInterface`. Defaults to `Muffin\Slug\Slugger\CakeSlugger`.
- `unique:`: tells if slugs should be unique. Set this to a callable if you want to customize how unique slugs are generated. Defaults to `true`.
- `scope`: extra conditions used when checking a slug for uniqueness.
- `implementedEvents`: events this behavior listens to. Defaults to `['Model.buildValidator' => 'buildValidator', 'Model.beforeSave' => 'beforeSave']`. By default the behavior adds validation for the `displayField` fields to make them required on record creating. If you don't want these auto added validations you can set `implementedEvents` to just `['Model.beforeSave' => 'beforeSave']`.
- `onUpdate`: Boolean indicating whether slug should be updated when updating record, defaults to `false`.
- `onDirty`: Boolean indicating whether slug should be updated when slug field is dirty (has a preset value custom value), defaults to `false`.

Sluggers
--------

[](#sluggers)

The plugin contains two sluggers:

### CakeSlugger

[](#cakeslugger)

The `CakeSlugger` uses `\Cake\Utility\Text::slug()` to generate slugs. In the behavior config you can set the `slugger` key as shown below to pass options to the `$options` arguments of `Text::slug()`.

```
'slugger' => [
    'className' => \Muffin\Slug\Slugger\CakeSlugger::class,
    'transliteratorId' => ''
]
```

### ConcurSlugger

[](#concurslugger)

The `ConcurSlugger` uses [concur/slugify](https://github.com/cocur/slugify) to generate slugs. You can use config array similar to the one shown above to pass options to `Cocur\Slugify\Slugify`'s constructor.

Patches &amp; Features
----------------------

[](#patches--features)

- Fork
- Mod, fix
- Test - this is important, so it's not unintentionally broken
- Commit - do not mess with license, todo, version, etc. (if you do change any, bump them into commits of their own that I can ignore when I pull)
- Pull request - bonus point for topic branches

To ensure your PRs are considered for upstream, you MUST follow the CakePHP coding standards.

Bugs &amp; Feedback
-------------------

[](#bugs--feedback)

License
-------

[](#license)

Copyright (c) 2015-Present, [Use Muffin](http://usemuffin.com) and licensed under [The MIT License](http://www.opensource.org/licenses/mit-license.php).

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance26

Infrequent updates — may be unmaintained

Popularity47

Moderate usage in the ecosystem

Community28

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 79.3% 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 ~217 days

Recently: every ~294 days

Total

14

Last Release

1010d ago

Major Versions

1.4.0 → 2.0.0-beta2019-12-18

2.1.1 → 3.0.02023-09-27

### Community

Maintainers

![](https://www.gravatar.com/avatar/ccb57ae849b67ade8d9c1e266bc2868183bbcf07fb6c66c2d45254a452272d54?d=identicon)[jadb](/maintainers/jadb)

![](https://www.gravatar.com/avatar/e31753bdd616948c7c8978ea9b5805378f75bfa62564e69c0aa2fd67aaf418c5?d=identicon)[ADmad](/maintainers/ADmad)

---

Top Contributors

[![ADmad](https://avatars.githubusercontent.com/u/142658?v=4)](https://github.com/ADmad "ADmad (119 commits)")[![jadb](https://avatars.githubusercontent.com/u/33527?v=4)](https://github.com/jadb "jadb (12 commits)")[![burzum](https://avatars.githubusercontent.com/u/162789?v=4)](https://github.com/burzum "burzum (6 commits)")[![curtisgibby](https://avatars.githubusercontent.com/u/1086964?v=4)](https://github.com/curtisgibby "curtisgibby (4 commits)")[![lorenzo](https://avatars.githubusercontent.com/u/37621?v=4)](https://github.com/lorenzo "lorenzo (3 commits)")[![bravo-kernel](https://avatars.githubusercontent.com/u/230500?v=4)](https://github.com/bravo-kernel "bravo-kernel (3 commits)")[![phillaf](https://avatars.githubusercontent.com/u/1533572?v=4)](https://github.com/phillaf "phillaf (1 commits)")[![davidyell](https://avatars.githubusercontent.com/u/49889?v=4)](https://github.com/davidyell "davidyell (1 commits)")[![jorgeandrescastro](https://avatars.githubusercontent.com/u/2861868?v=4)](https://github.com/jorgeandrescastro "jorgeandrescastro (1 commits)")

---

Tags

cakephpcakephp-pluginphpslugslugormcakephpmuffin

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[muffin/trash

Adds soft delete support to CakePHP ORM tables.

881.5M11](/packages/muffin-trash)[josegonzalez/cakephp-upload

CakePHP plugin to handle file uploading sans ridiculous automagic

5461.4M11](/packages/josegonzalez-cakephp-upload)[muffin/webservice

Simplistic webservices for CakePHP

88196.6k14](/packages/muffin-webservice)[riesenia/cakephp-duplicatable

CakePHP ORM plugin for duplicating entities (including related entities)

51408.2k4](/packages/riesenia-cakephp-duplicatable)[admad/cakephp-sequence

Sequence plugin for CakePHP to maintain ordered list of records

45518.5k7](/packages/admad-cakephp-sequence)[josegonzalez/cakephp-version

CakePHP ORM behavior to allow versioning of records

49154.7k](/packages/josegonzalez-cakephp-version)

PHPackages © 2026

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