PHPackages                             hyperlink/laravel-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. hyperlink/laravel-sluggable

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

hyperlink/laravel-sluggable
===========================

Create permanent seo friendly slugs for every model

00PHP

Since Feb 28Pushed 3y ago1 watchersCompare

[ Source](https://github.com/hyperlinkgroup/laravel-sluggable)[ Packagist](https://packagist.org/packages/hyperlink/laravel-sluggable)[ RSS](/packages/hyperlink-laravel-sluggable/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Slugs for Laravel - laravel-sluggable
=====================================

[](#slugs-for-laravel---laravel-sluggable)

[![Latest Version on Packagist](https://camo.githubusercontent.com/a17e89ece6c7d5b56fe4c604003ba694b90e4f8491ff9a49fca398f3524903e6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f68797065726c696e6b2f6c61726176656c2d736c75676761626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/hyperlink/laravel-sluggable)[![GitHub Tests Action Status](https://camo.githubusercontent.com/a66083a19c39ba02bd37798444891e1c3bf2af5b01bf17845a2d2428f4dc1540/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f68797065726c696e6b67726f75702f6c61726176656c2d736c75676761626c652f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/hyperlinkgroup/laravel-sluggable/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/9c5dc2350b5bb53a4ebace7441e108ff797f5e7a56c12d0432d5804706d68b6a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f68797065726c696e6b67726f75702f6c61726176656c2d736c75676761626c652f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/hyperlinkgroup/laravel-sluggable/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/647f27039b6452c452dfff7f2c6e8ed1779be0964588edd39fd1c291839564ee/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f68797065726c696e6b2f6c61726176656c2d736c75676761626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/hyperlink/laravel-sluggable)

Create permanent seo friendly slugs for every model

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

[](#installation)

You can install the package via composer:

```
composer require hyperlink/laravel-sluggable
```

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="laravel-sluggable-migrations"
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --tag="laravel-sluggable-config"
```

This is the contents of the published config file:

```
return [
    /*
     * The name of the table that will store the slugs.
     */
    'table' => 'slugs',

    /*
     * The name of the column that will store the slug.
     */
    'column' => 'slug',

    /*
     * The separator used to separate words in the slug.
     * ATTENTION: If you change this value
     * no existing slugs will be changed.
     */
    'separator' => '-',

    /*
     * The separator used to separate the slug from the counter.
     * If the slug already exists, a counter will be added.
     * ATTENTION: If you change this value
     * no existing slugs will be changed.
     */
    'counter_separator' => '_',

    /*
     * The max length of the slug excluding the counter.
     * ATTENTION: If you change this value to above 255
     * you must also publish the migration and
     * change column type in the database.
     */
    'max_length' => 255,

    /*
     * The model that will be used to generate the slug.
     * You can use your own model by extending the provided model.
     */
    'model' => Hyperlink\Sluggable\Models\Slug::class,
];
```

Usage
-----

[](#usage)

```
class Post extends Model
{
    use Sluggable; // Add this trait to your model

    // The column that will be used to generate the slug
    protected string $slugCreatedFrom = 'title';
}
```

The trait will register an observer that will generate the slug when the model is created or updated.

```
    public static function bootSluggable(): void
    {
        // ...
        static::created(/* ... */);

        static::updated(/* ... */);
        // ...
    }
```

You can overwrite it with

```
protected function makeSlug(): string
{
    return (string) sluggable($this->{$this->getSlugCreatedFrom()});
}
```

Testing
-------

[](#testing)

```
composer test
```

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Katalam](https://github.com/Katalam)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

13

—

LowBetter than 1% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity23

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/69b181264e5c9a7d89c80721247a92aae0cf9a970e65e55a31cb77cc62546e1d?d=identicon)[hyperlink](/maintainers/hyperlink)

---

Top Contributors

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

### Embed Badge

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

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

PHPackages © 2026

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