PHPackages                             abdulrhmansouda/muid - 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. abdulrhmansouda/muid

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

abdulrhmansouda/muid
====================

This package for unique id with dynamic options characters

1.2.1(2y ago)16311proprietaryPHPPHP &gt;=5.3.0

Since Aug 14Pushed 2y ago1 watchersCompare

[ Source](https://github.com/abdulrhmansouda/laravel_uuid)[ Packagist](https://packagist.org/packages/abdulrhmansouda/muid)[ RSS](/packages/abdulrhmansouda-muid/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (29)Used By (0)

laravel UUID/MUID
=================

[](#laravel-uuidmuid)

This package is for generating uuid but with custom length and charset.

Setup
-----

[](#setup)

### Instaltion

[](#instaltion)

Use the package manager [composer](https://getcomposer.org/) to install muid.

```
composer require abdulrhmansouda/muid
```

### Configuration

[](#configuration)

if you want to change the defalut value you can publish configurations files by run:

```
php artisan vendor:publish --tag=muid-config
```

Usage
-----

[](#usage)

inside your table migration

```
    public function up(): void
    {
        Schema::create('table_name', function (Blueprint $table) {
            $table->muid()->primary(); \\ by default the column name is "muid"
            $table->timestamps();
        });
    }
```

inside your model

```
use Illuminate\Database\Eloquent\Model;
use MUID\HasMUID;

class TableName extends Model
{
    use HasMUID;
}
```

That's it ^\_^

Customization
-------------

[](#customization)

you are able to add multiple column, change column\_name, length of the string inside column, the charset.

first of all to change column name you have to start from migration:

```
    public function up(): void
    {
        Schema::create('table_name', function (Blueprint $table) {
            $table->muid('id')->primary();
            $table->muid('unique_code', 5)->unique();
            $table->timestamps();
        });
    }
```

then from your model you can change the column\_name, length , charset as follow:

```
use Illuminate\Database\Eloquent\Model;
use MUID\HasMUID;

class TableName extends Model
{
    use HasMUID;

    protected static function get_muid_columns(): array
    {
        return [
            [
                'column_name'   => 'id',
                // 'length'    => 10, default length is 10
                // 'charset'   => '0123456789abcdefghijklmnopqrstuvwxyz', default chareset
            ],
            [
                'column_name'   => 'unique_code',
                'length'    => 5,
                'charset'   => '0123456789',
            ],
        ];
    }
}
```

Helper Function
---------------

[](#helper-function)

### when you want to generate muid manually.

[](#when-you-want-to-generate-muid-manually)

Depending on the model the parameters of length and charset will be taken automatically.

```
use Illuminate\Support\Str;

$unique_muid = Str::generateMUIDByModel(ModelName::class); // default column name is muid.

$unique_muid = Str::generateMUIDByModel(ModelName::class, 'column_name');
```

When you don't want to use model at all. you can generate unique muid depending on the table name.

```
use Illuminate\Support\Str;

$unique_muid = Str::generateMUIDByTable('table_name');
// default column_name = 'muid'
// default column_length = 10
// default charset = '0123456789abcdefghijklmnopqrstuvwxyz'

$unique_muid = Str::generateMUIDByTable('table_name', 'column_name', 5, '0123456789');
```

To add muid column to a table which has records
-----------------------------------------------

[](#to-add-muid-column-to-a-table-which-has-records)

after adding configuration to model you have to add in migration.

```
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::table('table_name', function (Blueprint $table) {
            $table->muid('new_column_name')->nullable();
        });

        TableName::all()->each(function ($model_instance) {
            $model_instance->generateMUID(['new_column_name']);
            $model_instance->save();
        });

        Schema::table('table_name', function (Blueprint $table) {
            $table->muid('new_column_name')
                ->nullable(false)
                ->change();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('table_name', function (Blueprint $table) {
            $table->dropColumn(['new_column_name']);
        });
    }
};
```

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

[](#contributing)

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License
-------

[](#license)

[MIT](https://choosealicense.com/licenses/mit/)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity48

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

Recently: every ~16 days

Total

28

Last Release

897d ago

### Community

Maintainers

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

---

Top Contributors

[![abdulrhmansouda](https://avatars.githubusercontent.com/u/92040330?v=4)](https://github.com/abdulrhmansouda "abdulrhmansouda (27 commits)")

### Embed Badge

![Health badge](/badges/abdulrhmansouda-muid/health.svg)

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

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M683](/packages/barryvdh-laravel-ide-helper)[orchestra/canvas

Code Generators for Laravel Applications and Packages

21017.2M157](/packages/orchestra-canvas)[kirschbaum-development/commentions

A package to allow you to create comments, tag users and more

12369.2k](/packages/kirschbaum-development-commentions)[glhd/special

1929.4k](/packages/glhd-special)[bjuppa/laravel-blog

Add blog functionality to your Laravel project

483.3k1](/packages/bjuppa-laravel-blog)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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