PHPackages                             enfil/sharding - 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. enfil/sharding

ActiveLibrary

enfil/sharding
==============

Laravel 5.1 sharding

261.5k7[1 issues](https://github.com/enfil/laravel-sharding/issues)[1 PRs](https://github.com/enfil/laravel-sharding/pulls)PHP

Since Dec 29Pushed 3y ago2 watchersCompare

[ Source](https://github.com/enfil/laravel-sharding)[ Packagist](https://packagist.org/packages/enfil/sharding)[ RSS](/packages/enfil-sharding/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

laravel-sharding
================

[](#laravel-sharding)

\################################################

**LEGACY!!!**
=============

[](#legacy)

CLOSED AND NOT SUPPORTED
========================

[](#closed-and-not-supported)

\################################################

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

[](#installation)

#### Download package

[](#download-package)

`composer require enfil/sharding`

#### Add to Providers

[](#add-to-providers)

Add `Enfil\Sharding\ShardingServiceProvider::class,` to the `providers` array in `/config/app.php`.

#### Add to Aliases

[](#add-to-aliases)

Add `'ShardManager'  => \Enfil\Sharding\Facades\ShardManager::class,` to the `alias` list in `/config/app.php`.

#### Publish config

[](#publish-config)

`php artisan vendor:publish --provider="Enfil\Sharding\ShardingServiceProvider" --tag="config" --force`

Configuration
-------------

[](#configuration)

You can configurate sharding for all your services in the `sharding.php` config file located in the `config` directory.

Usage
-----

[](#usage)

First of all you should set your service:

`\ShardManager::setService('auth');`

#### Adding data

[](#adding-data)

When you're inserting any element into your database you should generate unique ID for it. You can get next id using:

`$id = \ShardManager::getNextId();`

Than you can choose shard (database connection) using:

`$shard = \ShardManager::getShardById($id);`

Now you can insert your data to current shard:

```
\DB::connection($shard)->table('t')->insert(
    [...]
);

```

After inserting you should increment id-generator:

`\ShardManager::increment();`

#### Selecting data

[](#selecting-data)

To select your data by id you should get a shard:

`$shard = \ShardManager::getShardById($id);`

Than you can get data from current shard:

`DB::connection($shard)->table('t')->select(...);`

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity23

Early-stage or recently created project

 Bus Factor1

Top contributor holds 90.9% 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/62f48333c3a23d696a7e1edb9f534f957483dc582a3fd7d954d474531078c2f0?d=identicon)[enfil](/maintainers/enfil)

---

Top Contributors

[![enfil](https://avatars.githubusercontent.com/u/6010776?v=4)](https://github.com/enfil "enfil (10 commits)")[![jesseschutt](https://avatars.githubusercontent.com/u/353047?v=4)](https://github.com/jesseschutt "jesseschutt (1 commits)")

### Embed Badge

![Health badge](/badges/enfil-sharding/health.svg)

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

PHPackages © 2026

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