PHPackages                             coding-wisely/laravel-slug-auto-generator - 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. coding-wisely/laravel-slug-auto-generator

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

coding-wisely/laravel-slug-auto-generator
=========================================

Auto generating unique slugs for your Laravel model

v2.0(2y ago)51.4k↓50%[4 PRs](https://github.com/coding-wisely/laravel-slug-auto-generator/pulls)MITPHPPHP ^8.2CI passing

Since Feb 17Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/coding-wisely/laravel-slug-auto-generator)[ Packagist](https://packagist.org/packages/coding-wisely/laravel-slug-auto-generator)[ Docs](https://github.com/coding-wisely/laravel-slug-auto-generator)[ GitHub Sponsors](https://github.com/CodingWisely)[ RSS](/packages/coding-wisely-laravel-slug-auto-generator/feed)WikiDiscussions dev Synced 1mo ago

READMEChangelog (3)Dependencies (11)Versions (8)Used By (0)

[![Laravel Logo](img.png)](https://codingwisely.com)

Laravel Slug Generator Package
==============================

[](#laravel-slug-generator-package)

[![Latest Version on Packagist](https://camo.githubusercontent.com/ded7ddb76d61bdb9a7ea2e0d0cbb864d1a9483a07b42044ef2cb25071d51e928/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636f64696e672d776973656c792f6c61726176656c2d736c75672d6175746f2d67656e657261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/coding-wisely/laravel-slug-auto-generator)[![GitHub Tests Action Status](https://camo.githubusercontent.com/2b6dfb1db7b83584607fef275d0834621ae3c0d1f46eecae4dcc39ecdfc30f90/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f636f64696e672d776973656c792f6c61726176656c2d736c75672d6175746f2d67656e657261746f722f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/coding-wisely/laravel-slug-auto-generator/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/10c3f401ddc42765ee8ab07cb632990e0155ec620270017a95a6aee866b29683/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f636f64696e672d776973656c792f6c61726176656c2d736c75672d6175746f2d67656e657261746f722f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/coding-wisely/laravel-slug-auto-generator/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/b725ef81e54ad4c9839ad51b2299d29d73a32ebe6dc5d539d7d160432cca5a02/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636f64696e672d776973656c792f6c61726176656c2d736c75672d6175746f2d67656e657261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/coding-wisely/laravel-slug-auto-generator)

This package hosts a robust and flexible trait designed for effortless slug generation within Laravel applications. Whether you're building a blog, e-commerce platform, or any other web application, managing SEO-friendly URLs becomes seamless with this powerful solution.

Key Features
------------

[](#key-features)

- **Automatic Slug Creation**: Automatically generates slugs based on a specified field in your Eloquent models, eliminating the need for manual slug assignment.
- **Unique Slug Enforcement**: Ensures that generated slugs are unique within the database table, preventing conflicts and maintaining data integrity.
- **SEO-Friendly URLs**: Facilitates the creation of SEO-friendly URLs by generating slugs based on user-friendly field values.
- **Groupable Slugs**: Supports the generation of unique slugs within a specific group, allowing for distinct slugs across different categories or sections. This practically means that you can have the same slug in different categories/tasks/projects/posts/etc.
- **Customizable Configuration**: Easily configure the field used for slug generation via Laravel's flexible configuration system, adapting to diverse project requirements effortlessly.

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

[](#installation)

You can install the package via composer:

```
composer require coding-wisely/laravel-slug-auto-generator
```

You can publish the config file with `php artisan vendor:publish` and select CodingWisely package from the list.

This is the contents of the published config file:

```
// config for CodingWisely/SlugGenerator
// replace it with your model column
return [
    'sluggable_field' => 'name',
    'groupable_field' => null, // 'category_id',
];
```

Replace with your field.

Usage
-----

[](#usage)

1. **Integrate the Trait**: Simply integrate the `SlugGenerator` trait into your Eloquent model to unlock its powerful slug generation capabilities.
2. **Configuration**: Customize the slug generation behavior by modifying the `slug-auto-generator.php` configuration file located in your `config` directory.
3. **Effortless Integration**: With the trait seamlessly integrated into your model, enjoy automatic and unique slug generation without any additional setup.

Example
-------

[](#example)

```
use CodingWisely\SlugGenerator\SlugGenerator;
use Illuminate\Database\Eloquent\Model;

class YourModel extends Model
{
    use SlugGenerator;

    // Your model's attributes and methods...

    // override config file with
    public static function getSluggableField(): string
    {
        return 'title'; // your own field on Model
    }
    // if you want to have unique slugs in different categories (groupable, such as project_id, team_id, category_id, etc.)
    public static function getGroupableField(): ?string
    {
        return 'category_id'; // your own field on Model
    }
}
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

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

[](#security-vulnerabilities)

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

Credits
-------

[](#credits)

- [Vladimir Nikolic](https://github.com/CodingWisely)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance59

Moderate activity, may be stable

Popularity24

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

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

3

Last Release

759d ago

Major Versions

v1.0.1 → v2.02024-04-19

### Community

Maintainers

![](https://www.gravatar.com/avatar/3660336cb86277baabd729b38399053f1ee9945aa129b7b24a62c048d78bf533?d=identicon)[coding-wisely](/maintainers/coding-wisely)

---

Top Contributors

[![nezaboravi](https://avatars.githubusercontent.com/u/1515172?v=4)](https://github.com/nezaboravi "nezaboravi (27 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (10 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (8 commits)")

---

Tags

sluglaravellaravel 10laravel 11Unique slugsCodingWiselylaravel slugslaravel-slug-auto-generator

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/coding-wisely-laravel-slug-auto-generator/health.svg)

```
[![Health](https://phpackages.com/badges/coding-wisely-laravel-slug-auto-generator/health.svg)](https://phpackages.com/packages/coding-wisely-laravel-slug-auto-generator)
```

###  Alternatives

[ip2location/ip2location-laravel

Lookup for visitor's IP information, such as country, region, city, coordinates, zip code, time zone, ISP, domain name, connection type, area code, weather, MCC, MNC, mobile brand name, elevation and usage type.

83516.9k1](/packages/ip2location-ip2location-laravel)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[marcelweidum/filament-expiration-notice

Customize the livewire expiration notice

9169.0k4](/packages/marcelweidum-filament-expiration-notice)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)[hotwired-laravel/stimulus-laravel

Use Stimulus in your Laravel app

3015.3k1](/packages/hotwired-laravel-stimulus-laravel)

PHPackages © 2026

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