PHPackages                             corazzi/sluggable - 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. corazzi/sluggable

ActiveLibrary[Database &amp; ORM](/categories/database)

corazzi/sluggable
=================

Automatically create slugs for your Eloquent models by hooking into the creating event

v1.1.0(9y ago)21.1kMITPHP

Since Feb 7Pushed 9y ago1 watchersCompare

[ Source](https://github.com/corazzi/sluggable)[ Packagist](https://packagist.org/packages/corazzi/sluggable)[ RSS](/packages/corazzi-sluggable/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependenciesVersions (3)Used By (0)

Sluggable
=========

[](#sluggable)

Automatically create slugs for your Eloquent models by hooking into the creating event

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

[](#installation)

Simply run `composer require Corazzi/sluggable` in your Laravel project.

Usage
-----

[](#usage)

To add automatic slug generation to a model, use the `Corazzi\Sluggable\Sluggable` trait.

```
namespace Acme\Models;

use Illuminate\Database\Eloquent\Model;
use Corazzi\Sluggable\Sluggable;

class Post extends Model
{
    use Sluggable;
}
```

Now when you create a new model that uses the trait, it will look for a `name` column and generate a new slug, which it will save in the `slug` column.

```
$post = Post::create([
    'name' => 'My first post'
]);

$post->slug; // my-first-post
```

### Custom columns

[](#custom-columns)

If you would like to use different column names for your origin string and the slug, you can set the protected attributes `$slugOrigin` and `$slugColumn` on your model.

```
namespace Acme\Models;

use Illuminate\Database\Eloquent\Model;
use Corazzi\Sluggable\Sluggable;

class Post extends Model
{
    use Sluggable;

    protected $slugOrigin = 'title';

    protected $slugColumn = 'post_name';
}
```

#### Example

[](#example)

```
$post = Post::create([
    'title' => 'My second post'
]);

$post->post_name; // my-second-post
```

### Existing slugs

[](#existing-slugs)

If a slug exists for the model, it will automatically append an integer to the end of the slug until a unique one is generated.

```
// my-second-post already exists

$post = Post::create([
    'title' => 'My second post'
]);

$post->post_name; // my-second-post-1

$post = Post::create([
    'title' => 'My second post'
]);

$post->post_name; // my-second-post-2

// ...and so on
```

### Explicitly setting slugs

[](#explicitly-setting-slugs)

You can explicitly set a slug when creating a new model and the automatic generation will be skipped

```
$post = Post::create([
    'name' => 'How to explicitly set a slug',
    'slug' => 'explicitly-setting-slugs-with-sluggable'
]);

$post->slug; // explicitly-setting-slugs-with-sluggable
```

### Empty origin

[](#empty-origin)

If the origin column is empty, a `Corazzi\Sluggable\EmptyOriginException` will be thrown.

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity64

Established project with proven stability

 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

Every ~30 days

Total

2

Last Release

3399d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/915909?v=4)[Sacha Corazzi](/maintainers/corazzi)[@corazzi](https://github.com/corazzi)

---

Top Contributors

[![corazzi](https://avatars.githubusercontent.com/u/915909?v=4)](https://github.com/corazzi "corazzi (2 commits)")

---

Tags

eloquenteloquent-modelslaravellaravel-5-packagephpphp7

### Embed Badge

![Health badge](/badges/corazzi-sluggable/health.svg)

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

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k116.5M113](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)[pgvector/pgvector

pgvector support for PHP

198628.3k10](/packages/pgvector-pgvector)

PHPackages © 2026

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