PHPackages                             rollswan/centralized-attachment - 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. rollswan/centralized-attachment

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

rollswan/centralized-attachment
===============================

Provides centralized file management

1.4.15(3y ago)4871MITPHP

Since Dec 4Pushed 3y ago1 watchersCompare

[ Source](https://github.com/rollswan-acebedo/centralized-attachment)[ Packagist](https://packagist.org/packages/rollswan/centralized-attachment)[ RSS](/packages/rollswan-centralized-attachment/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (8)Dependencies (1)Versions (9)Used By (0)

Centralized File Attachment
===========================

[](#centralized-file-attachment)

Provides centralized storing of file attachment.

How to use?
-----------

[](#how-to-use)

1. Install `composer require rollswan/centralized-attachment`
2. Migrate `attachments` table by running `php artisan migrate`
3. Use `WithAttachments` trait in your controller

*Example:*

```
namespace App\Http\Controllers;

use Rollswan\CentralizedAttachment\Traits\WithAttachments;

class ArticleController extends Controller
{
    use WithAttachments;
}

```

4. Use `storeAttachment()` method in controller,

*Example:*

```
$this->storeAttachment(
    $file, // This is for the attach file or generated file
    $folderName, // Attach file will store in the /storage/app/ (for s3, bucket-name/)
    'App\Models\ModelName', // Owner Model
    $ownerModel, // Owner Model ID
    $generatedFileExtName, // Optional Param, To check whether the attach file is coming from file upload or generated file. Note: Set this file extension name argument if the attach file is generated/created file
    $disk // Optional Param, The default value is local disk. Simply change the filesystem disk if you wish to switch between the configured storage options
);

namespace App\Http\Controllers;

use Rollswan\CentralizedAttachment\Models\Attachment;
use Rollswan\CentralizedAttachment\Traits\WithAttachments;

class ArticleController extends Controller
{
    use WithAttachments;

    /**
     * Creates a new article.
     *
     * @param  CreateArticleRequest $request
     * @return \Illuminate\Http\RedirectResponse
     */
    public function create(CreateArticleRequest $request)
    {
        // Create the article
        $article = Article::create($request->except('_token'));

        // Process attachments, if any
        if (!empty($request->attachments)) {
            $this->storeArticleAttachments($article->id, $request->attachments);
        }

        session()->flash('success', "Article has been successfully created.");
        return back();
    }

    /**
     * Store article attachments.
     *
     * @param integer $articleId
     * @param \Illuminate\Http\UploadedFile $attachments
     */
    private function storeArticleAttachments($articleId, $attachments)
    {
        foreach ($request->attachments as $attachment) {
            $this->storeAttachment(
                $attachment,
                'articles',
                'App\Models\Article',
                $articleId
            );
        }
    }
}

```

5. Use `Attachment` model in controller

*Example:*

```
namespace App\Http\Controllers;

use Rollswan\CentralizedAttachment\Models\Attachment;
use Rollswan\CentralizedAttachment\Traits\WithAttachments;

class ArticleController extends Controller
{
    use WithAttachments;

    /**
     * View attachment.
     *
     * @param  string $uuid
     * @return \Symfony\Component\HttpFoundation\BinaryFileResponse
     */
    public function viewAttachment($uuid)
    {
        $attachment = Attachment::find($uuid);
        if (!$attachment) {
            abort(404);
        }

        return $this->streamAttachment($attachment, 'application/pdf');
    }
}

```

6. Use `deleteAttachment()` method in controller

*Example:*

```
namespace App\Http\Controllers;

use Rollswan\CentralizedAttachment\Models\Attachment;
use Rollswan\CentralizedAttachment\Traits\WithAttachments;

class ArticleController extends Controller
{
    /**
     * Delete article attachments.
     *
     * @param integer $articleId
     */
    private function deleteArticleAttachment($articleId)
    {
        // Get the article attachments
        $attachments = Attachment::where('owner_model', 'App\Models\Article')
            ->where('owner_id', $articleId)
            ->get();

        foreach ($attachments as $attachment) {
            $this->deleteAttachment($attachment);
        }
    }
}

```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity59

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

Recently: every ~159 days

Total

8

Last Release

1342d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/30310708?v=4)[rollswan](/maintainers/rollswan)[@Rollswan](https://github.com/Rollswan)

---

Top Contributors

[![rollswan-acebedo](https://avatars.githubusercontent.com/u/62542042?v=4)](https://github.com/rollswan-acebedo "rollswan-acebedo (7 commits)")

### Embed Badge

![Health badge](/badges/rollswan-centralized-attachment/health.svg)

```
[![Health](https://phpackages.com/badges/rollswan-centralized-attachment/health.svg)](https://phpackages.com/packages/rollswan-centralized-attachment)
```

###  Alternatives

[knplabs/gaufrette

PHP library that provides a filesystem abstraction layer

2.5k39.8M123](/packages/knplabs-gaufrette)[google/cloud-storage

Cloud Storage Client for PHP

34390.8M125](/packages/google-cloud-storage)[illuminate/filesystem

The Illuminate Filesystem package.

15261.6M2.6k](/packages/illuminate-filesystem)[superbalist/flysystem-google-storage

Flysystem adapter for Google Cloud Storage

26320.6M30](/packages/superbalist-flysystem-google-storage)[creocoder/yii2-flysystem

The flysystem extension for the Yii framework

2931.7M62](/packages/creocoder-yii2-flysystem)[flowjs/flow-php-server

PHP library for handling chunk uploads. Works with flow.js html5 file uploads.

2451.6M15](/packages/flowjs-flow-php-server)

PHPackages © 2026

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