PHPackages                             alkafi1/bangla-slug - 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. alkafi1/bangla-slug

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

alkafi1/bangla-slug
===================

A Laravel package for generating slugs from Bengali text.

10PHP

Since Apr 23Pushed 1mo agoCompare

[ Source](https://github.com/alkafi1/laravel-bangla-slug)[ Packagist](https://packagist.org/packages/alkafi1/bangla-slug)[ RSS](/packages/alkafi1-bangla-slug/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel BanglaSlug
==================

[](#laravel-banglaslug)

A powerful, robust, and easy-to-use Laravel package for generating slugs from Bengali text. It seamlessly removes special characters, supports English-Bengali mixed strings, and safely handles Emojis, numbers, and complex conjuncts (যুক্তাক্ষর).

Features
--------

[](#features)

- **Accurate Slug Generation**: Keeps Bengali characters, letters, and numbers intact.
- **Eloquent Trait included**: Automatically generate unique slugs in your database models on saving.
- **Customizable**: Set maximum slug length, strip or keep English characters, and define custom string replacements.
- **Global Helper Function**: Use `bangla_slug('text')` anywhere in your application.
- **Tested &amp; Reliable**: Extensive test coverage including difficult edge cases.

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

[](#installation)

You can install the package via composer:

```
composer require alkafi1/bangla-slug
```

*(Note: Since this is currently a local package, make sure to add it to your project's repository list or publish it to Packagist first).*

### Publish Configuration

[](#publish-configuration)

Optionally, you can publish the config file to customize the default behavior:

```
php artisan vendor:publish --tag="bangla-slug-config"
```

This will create a `config/bangla-slug.php` file in your application where you can change the default separator, toggle English characters, set a max length, and define custom character replacements.

---

Usage
-----

[](#usage)

### 1. Using the Facade

[](#1-using-the-facade)

```
use Alkafi1\BanglaSlug\Facades\BanglaSlug;

$slug = BanglaSlug::make('আমার সোনার বাংলা');
// Result: 'আমার-সোনার-বাংলা'
```

### 2. Using the Helper Function

[](#2-using-the-helper-function)

You can quickly generate a slug anywhere using the global helper function:

```
$slug = bangla_slug('Laravel এর সাথে বাংলা Slug');
// Result: 'laravel-এর-সাথে-বাংলা-slug'
```

### 3. Passing Options Dynamically

[](#3-passing-options-dynamically)

You can pass an array of options to customize the behavior on the fly:

```
$slug = bangla_slug('আমার সোনার বাংলা @ 2026', [
    'separator' => '_',          // Use underscore instead of hyphen
    'max_length' => 15,          // Truncate length
    'keep_english' => false,     // Strip out English letters
    'replacements' => [          // Custom replacements before slugifying
        '@' => 'at'
    ]
]);
```

---

Eloquent Model Integration
--------------------------

[](#eloquent-model-integration)

The package comes with a handy trait `HasBanglaSlug` to automatically generate **unique** slugs when you create or update an Eloquent model.

### Basic Setup

[](#basic-setup)

```
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Alkafi1\BanglaSlug\Traits\HasBanglaSlug;

class Post extends Model
{
    use HasBanglaSlug;

    protected $fillable = ['title', 'slug', 'content'];
}
```

Now, whenever you create a `Post`, the `slug` field will be automatically populated based on the `title` field. If a duplicate exists, it will append a number (e.g., `আমার-সোনার-বাংলা-1`).

### Customizing the Fields

[](#customizing-the-fields)

If your database columns are named differently (e.g., `name` instead of `title`, or `url_slug` instead of `slug`), you can easily override the default methods in your model:

```
class Category extends Model
{
    use HasBanglaSlug;

    // The field in the DB to save the slug to
    public function getSlugField(): string
    {
        return 'url_slug';
    }

    // The field to generate the slug from
    public function getSlugSourceField(): string
    {
        return 'name';
    }
}
```

Testing
-------

[](#testing)

This package is thoroughly tested. To run the tests, clone the repository and run:

```
composer install
vendor/bin/phpunit
```

License
-------

[](#license)

The MIT License (MIT). Please see License File for more information.

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance60

Regular maintenance activity

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

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/795751d1db419f4a822b0329a8e258a7763c888d446cd91247dfe7d7758997ff?d=identicon)[alkafi1](/maintainers/alkafi1)

---

Top Contributors

[![alkafi2-web](https://avatars.githubusercontent.com/u/179749689?v=4)](https://github.com/alkafi2-web "alkafi2-web (3 commits)")

### Embed Badge

![Health badge](/badges/alkafi1-bangla-slug/health.svg)

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

###  Alternatives

[space48/auto-value

Generated immutable value classes for PHP7.1+

291.6k](/packages/space48-auto-value)

PHPackages © 2026

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