PHPackages                             afzalsabbir/slug-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. afzalsabbir/slug-generator

ActiveLibrary

afzalsabbir/slug-generator
==========================

A simple package to generate slug from string for Laravel

v0.0.1-alpha-2(3y ago)250MITPHPPHP ^7.0|^8.0

Since Sep 17Pushed 3y ago1 watchersCompare

[ Source](https://github.com/AfzalSabbir/slug-generator)[ Packagist](https://packagist.org/packages/afzalsabbir/slug-generator)[ RSS](/packages/afzalsabbir-slug-generator/feed)WikiDiscussions master Synced 1mo ago

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

SlugGenerator - Laravel Slug Generator
======================================

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

> A Laravel package to generate slugs for your models.

[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/9302a0edad4f8cf72d10ec0318c491f5287a0b75c65a12b9e3888e25d8372370/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f61667a616c7361626269722f736c75672d67656e657261746f722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/afzalsabbir/slug-generator)[![Quality Score](https://camo.githubusercontent.com/6d6f828881ba6c5653c5013c7e55eea5fbcaaff53bfab81ec37ee57b4917c91a/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f61667a616c7361626269722f736c75672d67656e657261746f722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/afzalsabbir/slug-generator)

[![Latest Stable Version](https://camo.githubusercontent.com/75f96ea413c5acd3debdf17ee6b0016aad7e822889dcf02722e33813fecbb7d0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f61667a616c7361626269722f736c75672d67656e657261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/afzalsabbir/slug-generator)[![Latest Unstable Version](https://camo.githubusercontent.com/344e5d57023ea2e730eb37271b4a19aab69c324829cb81f6cca20770c0101c19/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f767072652f61667a616c7361626269722f736c75672d67656e657261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/afzalsabbir/slug-generator)[![Total Downloads](https://camo.githubusercontent.com/227c0a1b602a9b35e58e572090d75586e1222747bfa31ac304dcd400c8c3eab4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f61667a616c7361626269722f736c75672d67656e657261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/afzalsabbir/slug-generator)

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

[](#installation)

You can install the package via composer:

```
composer require afzalsabbir/slug-generator
```

Usage
-----

[](#usage)

- Using this package is very simple. Just use the `SlugGenerator` trait in your model and it'll automatically generate a slug for you. It'll use default configuration. ```
    // ...
    use AfzalSabbir\SlugGenerator\SlugGenerator;
    use Illuminate\Database\Eloquent\Model;
    // ...

    class Post extends Model
    {
        // ...
        use SlugGenerator;
        // ...
    }
    ```
- Publish the config file to customize the slug generation.
    *\[**Note:** if facing any issue run `php artisan vendor:publish` and find `AfzalSabbir\SlugGenerator\SlugGeneratorServiceProvider` to publish\]*```
    php artisan vendor:publish --provider="AfzalSabbir\SlugGenerator\SlugGeneratorServiceProvider" --tag="config"
    ```
- You can also configure the slug generation in your model. ```
    namespace App\Models;

    use AfzalSabbir\SlugGenerator\SlugGenerator;
    use Illuminate\Database\Eloquent\Model;
    // ...

    class Post extends Model
    {
        // ...
        use SlugGenerator;

        // ...
        protected $slugGenerator = [
            "set-on-create" => true, // Whether to set the slug when the model is created
            "set-on-update" => false, // Whether to update the slug when the target field is updated
            "target-field"  => "title", // The field that will be used to generate the slug
            "separator"     => "-", // The separator that will be used to separate the words
            "slug-field"    => "slug", // The field that will be used to store the slug
        ];

        // ...
    }
    ```
- You can also use the `generateSlug(Model $model)` helper method to generate a slug. ```
    use AfzalSabbir\SlugGenerator\SlugGenerator;
    use App\Models\Post;
    // ...

    $post = Post::find(1);
    $post->title = "Hello World";
    $post->slug = generateSlug($post);
    $post->save();
    ```

Testing
-------

[](#testing)

Run the tests with:

```
vendor/bin/phpunit
```

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

[](#contributing)

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

Security
--------

[](#security)

If you discover any security-related issues, please email  instead of using the issue tracker.

License
-------

[](#license)

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

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 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 ~0 days

Total

3

Last Release

1331d ago

### Community

Maintainers

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

---

Top Contributors

[![AfzalSabbir](https://avatars.githubusercontent.com/u/39697431?v=4)](https://github.com/AfzalSabbir "AfzalSabbir (18 commits)")

---

Tags

laravellaravel-sluglaravel-slug-generatorslugslug-generatorslugsluggableslug-generator

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[cviebrock/eloquent-sluggable

Easy creation of slugs for your Eloquent models in Laravel

4.0k13.6M253](/packages/cviebrock-eloquent-sluggable)[ausi/slug-generator

Slug Generator

8002.2M22](/packages/ausi-slug-generator)

PHPackages © 2026

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