PHPackages                             vidwan/tenant-buckets - 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. [File &amp; Storage](/categories/file-storage)
4. /
5. vidwan/tenant-buckets

ActiveLibrary[File &amp; Storage](/categories/file-storage)

vidwan/tenant-buckets
=====================

Automatically Provision AWS S3 Buckets for tenants.

v0.1.1(3y ago)2911.7k↓28.4%7[4 PRs](https://github.com/fourdotsix/tenant-buckets/pulls)MITPHPPHP ^8.0CI passing

Since Feb 13Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/fourdotsix/tenant-buckets)[ Packagist](https://packagist.org/packages/vidwan/tenant-buckets)[ Docs](https://github.com/vidwan-co/tenant-buckets)[ Fund](https://www.buymeacoffee.com/shashwatmishra)[ GitHub Sponsors](https://github.com/secrethash)[ RSS](/packages/vidwan-tenant-buckets/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (5)Versions (10)Used By (0)

Provision S3 Buckets for each tenant.
=====================================

[](#provision-s3-buckets-for-each-tenant)

[![Vidwan/Tenant-Buckets](https://camo.githubusercontent.com/4e4de134a3c4c2011c2eb8d1e636267649f238d4c0b8e54efd3df0d8cba15ccb/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f54656e616e742532304275636b6574732e706e673f7468656d653d6461726b267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d76696477616e25324674656e616e742d6275636b657473267061747465726e3d63697263756974426f617264267374796c653d7374796c655f31266465736372697074696f6e3d50726f766973696f6e2b53332b4275636b6574732b666f722b74656e616e74732e266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313030707826696d616765733d636f6c6c656374696f6e)](https://camo.githubusercontent.com/4e4de134a3c4c2011c2eb8d1e636267649f238d4c0b8e54efd3df0d8cba15ccb/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f54656e616e742532304275636b6574732e706e673f7468656d653d6461726b267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d76696477616e25324674656e616e742d6275636b657473267061747465726e3d63697263756974426f617264267374796c653d7374796c655f31266465736372697074696f6e3d50726f766973696f6e2b53332b4275636b6574732b666f722b74656e616e74732e266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313030707826696d616765733d636f6c6c656374696f6e)[![Latest Version on Packagist](https://camo.githubusercontent.com/6e78e972b066c651aea958eddcd242ce7f20ecfaadf9449548f694f4b122371f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f76696477616e2f74656e616e742d6275636b6574732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vidwan/tenant-buckets)[![Tests](https://github.com/vidwanco/tenant-buckets/actions/workflows/run-tests.yml/badge.svg?branch=main)](https://github.com/vidwanco/tenant-buckets/actions/workflows/run-tests.yml)[![Total Downloads](https://camo.githubusercontent.com/cad5d077a9c81782b0a2b5d396255860eb3e148864ec03b03a9ccb1421870645/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f76696477616e2f74656e616e742d6275636b6574732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vidwan/tenant-buckets)

Automatically Provision AWS S3 Buckets for each tenant. It's an Extention for [stancl/tenancy](https://github.com/stancl/tenancy). For more details refer to [TenancyForLaravel](https://tenancyforlaravel.com/).

Tenancy V4.x
------------

[](#tenancy-v4x)

Use branch [tenancy-v4](https://github.com/vidwanco/tenant-buckets/tree/tenancy-v4) for Tenancy v4.x versions.

Use `dev-tenancy-v4` for pulling latest changes from branch.

```
composer require vidwan/tenant-buckets:dev-tenancy-v4
```

Or just use a Release Candidate:

```
composer require vidwan/tenant-buckets:^4.0.0-rc
```

Concept
-------

[](#concept)

The concept is simple, to automatically provison a new AWS S3 bucket for tenant on registration and update the same on the central database's tenant table &amp; data coloumn under `tenant_bucket`. Then using a bootstrapper updating the bucket in config `filesystems.disks.s3.bucket` during runtime when in Tenant's context and then reverting it back on central context.

### Roadmap

[](#roadmap)

- Automatic Bucket Creation
- Selecting the created bucket during Tenancy Bootstrapping.
- Deletion of Bucket when the Tenant is deleted.
- Testing with Amazon S3 service.

> **Note:** I have still not tested this package under ***production*** environment or with a real AWS S3 Bucket. I have only tested it under ***development*** environment using [MinIO](https://min.io/). I will update this after testing it on AWS S3 Bucket with an additional section on AWS IAM Policy Setup for creating the buckets using `aws-sdk-php`. Untill then, if you have tested, a PR is welcome.

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

[](#installation)

You can install the package via composer:

```
composer require vidwan/tenant-buckets
```

Usage
-----

[](#usage)

### 1. Filesystem Config Setup

[](#1-filesystem-config-setup)

Ensure your S3 configuration has all the Key/Value pairs, as below:

**File:** `config/filesystems.php`

```
        's3' => [
            'driver' => 's3',
            'key' => env('AWS_ACCESS_KEY_ID'),
            'secret' => env('AWS_SECRET_ACCESS_KEY'),
            'region' => env('AWS_DEFAULT_REGION'),
            'bucket' => env('AWS_BUCKET'),
            'url' => env('AWS_URL'),
            'endpoint' => env('AWS_ENDPOINT'),
            'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
        ],
```

> Using Minio for development? Make sure to update your `.env` with `AWS_USE_PATH_STYLE_ENDPOINT=true`

### 2. Tenancy Config

[](#2-tenancy-config)

There are two parts in tenancy config to take care of.

#### Part **a**.

[](#part-a)

Add the `TenantBucketBootstrapper::class` to the tenancy config file under `bootstrappers`.

```
Vidwan\TenantBuckets\Bootstrappers\TenantBucketBootstrapper::class
```

**File:** `config/tenancy.php`

```
    'bootstrappers' => [
        // Tenancy Bootstrappers
        Vidwan\TenantBuckets\Bootstrappers\TenantBucketBootstrapper::class,
    ],
```

#### Part **b**.

[](#part-b)

Make sure the `s3` is commented in `tenancy.filesystem.disks` config or else it conflicts with the tenancy itself.

**File:** `config/tenancy.php`

```
    'filesystem' => [
        'suffix_base' => 'tenant',
        'disks' => [
            'local',
            'public',
            // 's3', // Make sure this stays commented
        ],
    ],
```

### 3. Job Pipeline

[](#3-job-pipeline)

Add `Vidwan\TenantBuckets\Jobs\CreateTenantBucket` &amp; `Vidwan\TenantBuckets\Jobs\DeleteTenantBucket` in `JobPipeline::make()`. As the name suggests, the former Creates a New Bucket on Tenant Creation and the later Deletes it when a Tenant is being Deleted.

**File:** `app/Providers/TenancyServiceProviders.php`

```
use Vidwan\TenantBuckets\Jobs\CreateTenantBucket;
use Vidwan\TenantBuckets\Jobs\DeleteTenantBucket;

...

    public function events()
    {
        return [
            // Tenant events
            ...
            Events\TenantCreated::class => [
                JobPipeline::make([
                    Jobs\CreateDatabase::class,
                    Jobs\MigrateDatabase::class,
                    Jobs\SeedDatabase::class,
                    // Your own jobs to prepare the tenant.
                    // Provision API keys, create S3 buckets, anything you want!
                    CreateTenantBucket::class, // send(function (Events\TenantCreated $event) {
                    return $event->tenant;
                })->shouldBeQueued(false),
            ],
            ...
            Events\DeletingTenant::class => [
                JobPipeline::make([
                    DeleteTenantBucket::class, // send(function (Events\DeletingTenant $event) {
                    return $event->tenant;
                })->shouldBeQueued(false),
            ],
            ...
        ];
    }
```

Cheers! 🥳

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

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

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

[](#security-vulnerabilities)

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

Credits
-------

[](#credits)

- [Shashwat Mishra](https://github.com/secrethash)
- [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

Maintenance51

Moderate activity, may be stable

Popularity37

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 67.3% 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 ~258 days

Total

5

Last Release

524d ago

Major Versions

v0.1.1 → v4.0.0-rc12024-12-11

PHP version history (2 changes)v0.0.1PHP ^8.0

v4.0.0-rc1PHP ^8.2

### Community

Maintainers

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

---

Top Contributors

[![secrethash](https://avatars.githubusercontent.com/u/11258035?v=4)](https://github.com/secrethash "secrethash (37 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (9 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (9 commits)")

---

Tags

awsaws-s3laraveltenancyforlaravelVidwan Co.tenant-bucketsTenancy For Laraveltenancyforlaravel

###  Code Quality

TestsPest

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/vidwan-tenant-buckets/health.svg)

```
[![Health](https://phpackages.com/badges/vidwan-tenant-buckets/health.svg)](https://phpackages.com/packages/vidwan-tenant-buckets)
```

###  Alternatives

[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.6k263.6M790](/packages/league-flysystem-aws-s3-v3)[aws/aws-sdk-php-laravel

A simple Laravel 9/10/11/12/13 service provider for including the AWS SDK for PHP.

1.7k35.6M75](/packages/aws-aws-sdk-php-laravel)[humanmade/s3-uploads

WordPress plugin to store uploads on S3

2.1k2.4M9](/packages/humanmade-s3-uploads)[aws/aws-sdk-php-resources

A resource-oriented API for interacting with AWS services

1381.8M10](/packages/aws-aws-sdk-php-resources)[frostealth/yii2-aws-s3

An Amazon S3 component for Yii2

90698.9k5](/packages/frostealth-yii2-aws-s3)[aws/aws-sdk-php-silex

A simple Silex service provider for including the AWS SDK for PHP.

84624.6k2](/packages/aws-aws-sdk-php-silex)

PHPackages © 2026

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