PHPackages                             ranitachi/filemanager-laravel - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. ranitachi/filemanager-laravel

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

ranitachi/filemanager-laravel
=============================

A secure, modular, and extensible File Manager for Laravel with RBAC, multi-storage, audit log, and WYSIWYG editor integration.

v1.0.3(2mo ago)022MITPHP ^8.0|^8.1|^8.2

Since May 25Compare

[ Source](https://github.com/ranitachi/FilemanagerLaravel)[ Packagist](https://packagist.org/packages/ranitachi/filemanager-laravel)[ RSS](/packages/ranitachi-filemanager-laravel/feed)WikiDiscussions Synced 3w ago

READMEChangelogDependencies (13)Versions (5)Used By (0)

🗂 Laravel Secure File Manager
=============================

[](#-laravel-secure-file-manager)

[![Latest Version](https://camo.githubusercontent.com/e9bc2b3166c16decf25586d141f572d9dec238286b1f96e797df1a3c186afd94/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f72616e6974616368692f66696c656d616e616765722d6c61726176656c2e737667)](https://packagist.org/packages/ranitachi/filemanager-laravel)[![PHP Version](https://camo.githubusercontent.com/83dd395020c37276225039739320f6c8e7e99963ab21ee3d09282cb48dad2a60/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312532422d626c7565)](https://php.net)[![Laravel](https://camo.githubusercontent.com/add0a2daaf51dd84233459fc84033647bab96087f8cefa4e7b8e3a56e1f52451/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d313025324225323025374325323031312532422d726564)](https://laravel.com)[![License](https://camo.githubusercontent.com/f8df3091bbe1149f398a5369b2c39e896766f9f6efba3477c63e9b4aa940ef14/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e)](LICENSE)

A **secure, modular, and extensible** File Manager package for Laravel 10/11.
Built as a drop-in replacement for `unisharp/laravel-filemanager` with enterprise-grade security, granular RBAC, multi-storage support, and native WYSIWYG editor integration.

---

✨ Features
----------

[](#-features)

FeatureDetails🔐 **Security**Path traversal prevention, magic-byte MIME validation, signed URLs, ClamAV hook🗄 **Multi-Storage**Local, S3, MinIO — swap via config, no code change👥 **RBAC**Per-file / per-folder permissions for users and roles, with inheritance📋 **Audit Log**Every action (upload, download, delete, move) is logged with IP and user-agent🖼 **Thumbnails**Auto-generated via Intervention Image 3 (GD or Imagick)✂️ **Full CRUD**Upload, rename, move, copy, soft-delete, restore, permanent delete🔗 **Share Links**Temporary signed URLs with expiry, download limit, and optional password🧩 **Editor Integration**CKEditor 5, TinyMCE, Summernote — single-file JS plugins included🎣 **Event Hooks**`FileUploaded`, `FileDeleted`, `FileDownloaded`, `FileMoved`, `FolderCreated`📦 **Artisan Commands**`filemanager:install`, `filemanager:purge-trash`⚡ **Rate Limiting**Configurable upload rate limit per user/IP---

Requirements
------------

[](#requirements)

- **PHP** 8.1+
- **Laravel** 10.x or 11.x
- **Database** MySQL 8.0+ / PostgreSQL 13+ / SQLite (testing)
- **PHP Extensions** `gd` or `imagick` (for thumbnails), `finfo` (MIME detection)

---

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

[](#installation)

### 1. Install via Composer

[](#1-install-via-composer)

```
composer require ranitachi/filemanager-laravel
```

### 2. Run the installer

[](#2-run-the-installer)

```
php artisan filemanager:install
```

This publishes config, migrations, and assets — then runs migrations automatically.

### 3. Manual install (alternative)

[](#3-manual-install-alternative)

```
php artisan vendor:publish --tag=filemanager-config
php artisan vendor:publish --tag=filemanager-migrations
php artisan vendor:publish --tag=filemanager-assets
php artisan migrate
php artisan storage:link
```

---

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

[](#configuration)

After publishing, edit `config/filemanager.php`:

```
// Storage driver
'disk'            => env('FILEMANAGER_DISK', 'local'),
'storage_adapter' => \Ranitachi\FileManager\Storage\LocalAdapter::class,

// Upload constraints
'max_upload_size_kb' => 10240,   // 10 MB
'allowed_extensions' => ['jpg', 'png', 'pdf', 'docx', ...],

// Rate limiting
'rate_limit' => [
    'uploads_per_minute' => 20,
],

// Thumbnails
'thumbnails' => [
    'enabled' => true,
    'width'   => 300,
    'height'  => 300,
    'driver'  => 'gd',   // or 'imagick'
],
```

### `.env` Variables

[](#env-variables)

```
FILEMANAGER_DISK=local
FILEMANAGER_MAX_SIZE=10240
FILEMANAGER_SIGNED_URL_EXPIRE=60

# S3 / MinIO
FILEMANAGER_ADAPTER=Ranitachi\FileManager\Storage\S3Adapter
FILEMANAGER_S3_KEY=your-key
FILEMANAGER_S3_SECRET=your-secret
FILEMANAGER_S3_REGION=ap-southeast-1
FILEMANAGER_S3_BUCKET=your-bucket

# MinIO only
FILEMANAGER_S3_ENDPOINT=http://minio:9000

# ClamAV (optional)
FILEMANAGER_AV_ENABLED=false
FILEMANAGER_AV_HOST=localhost
FILEMANAGER_AV_PORT=3310
```

---

API Reference
-------------

[](#api-reference)

All API routes are prefixed with `/api/v1/filemanager` and require a Bearer token.

### Files

[](#files)

MethodEndpointDescription`GET``/files`Browse files (with `folder_id`, `search`, `sort` params)`POST``/upload`Upload a file (multipart)`GET``/files/{id}`Get file metadata`GET``/files/{id}/download`Download file`GET``/files/{id}/preview`Preview file (inline stream)`PATCH``/files/{id}/rename`Rename file`POST``/files/{id}/move`Move to another folder`POST``/files/{id}/copy`Copy to another folder`POST``/files/{id}/restore`Restore from trash`DELETE``/files/{id}`Soft delete (pass `permanent: true` for hard delete)### Folders

[](#folders)

MethodEndpointDescription`GET``/folders`Folder tree`POST``/folders`Create folder`PATCH``/folders/{id}`Rename folder`DELETE``/folders/{id}`Delete folder### Permissions

[](#permissions)

MethodEndpointDescription`GET``/{type}/{id}/permissions`List permissions on file/folder`POST``/{type}/{id}/permissions`Grant permission to user/role`DELETE``/permissions/{id}`Revoke a specific permission### Share Links

[](#share-links)

MethodEndpointDescription`POST``/files/{id}/share`Create a share link`DELETE``/share/{token}/revoke`Revoke a share link`GET``/share/{token}`Public share page`GET``/share/{token}/download`Public download---

Usage Examples
--------------

[](#usage-examples)

### Via Facade

[](#via-facade)

```
use Ranitachi\FileManager\Facades\FileManager;

// Upload
$file = FileManager::upload($request->file('document'), $folderId);

// Browse with pagination
$files = FileManager::browse($folderId, [
    'per_page' => 20,
    'sort'     => 'created_at',
    'order'    => 'desc',
    'search'   => 'report',
]);

// Download (returns StreamedResponse)
return FileManager::download($fileId);

// Move
FileManager::move($fileId, $newFolderId);

// Delete (soft)
FileManager::delete($fileId);

// Delete (permanent — admin only)
FileManager::delete($fileId, permanent: true);
```

### Granting Permissions

[](#granting-permissions)

```
use Ranitachi\FileManager\Services\PermissionService;

$service = app(PermissionService::class);

// Grant read+write to a specific user on a folder
$service->grant(
    resource:      $folder,
    grantableId:   $userId,
    grantableType: App\Models\User::class,
    permissions:   ['read', 'write'],
    expiresAt:     now()->addDays(30),
);

// Check permission
$canDelete = $service->can($user, $file, 'delete'); // bool
```

### Creating a Share Link

[](#creating-a-share-link)

```
use Ranitachi\FileManager\Services\ShareService;

$share = app(ShareService::class)->create(
    fileId:           $file->id,
    expiresInMinutes: 1440,    // 24 hours
    maxDownloads:     10,
    password:         'secret',
);

echo $share->getShareUrl(); // https://yourapp.com/filemanager/share/AbCdEf...
```

### Listening to Events

[](#listening-to-events)

```
// In EventServiceProvider or config/filemanager.php 'listen' key:

use Ranitachi\FileManager\Events\FileUploaded;

class NotifyOnUpload
{
    public function handle(FileUploaded $event): void
    {
        \Log::info("File uploaded: {$event->file->name} by user {$event->uploadedBy->id}");
    }
}
```

---

WYSIWYG Editor Integration
--------------------------

[](#wysiwyg-editor-integration)

### CKEditor 5

[](#ckeditor-5)

```

import { FileManagerPlugin } from '/vendor/filemanager/js/ckeditor-plugin.js';

ClassicEditor.create(document.querySelector('#editor'), {
    extraPlugins: [ FileManagerPlugin ],
    fileManager:  { pickerUrl: '/filemanager/picker' },
});

```

### TinyMCE

[](#tinymce)

```

FileManagerTinyMCE.init('#editor', {
    pickerUrl: '/filemanager/picker',
});

```

### Summernote

[](#summernote)

```

$('#editor').summernote(
    FileManagerSummernote.config({ pickerUrl: '/filemanager/picker' })
);

```

The picker opens as a popup window. When a file is selected, a callback fires in the parent window and automatically inserts the file URL into the editor.

---

Artisan Commands
----------------

[](#artisan-commands)

```
# One-step installation wizard
php artisan filemanager:install

# Purge files trashed more than 30 days ago (configurable)
php artisan filemanager:purge-trash

# Dry run (show what would be deleted)
php artisan filemanager:purge-trash --dry-run

# Custom retention period
php artisan filemanager:purge-trash --days=7

# Schedule it in Console/Kernel.php or routes/console.php
$schedule->command('filemanager:purge-trash --force')->weekly();
```

---

Security
--------

[](#security)

This package implements multiple layers of defence:

**Upload Security**

- MIME type validated with PHP `finfo` (content-based, not extension-based)
- Extension cross-checked against MIME whitelist to prevent spoofing
- Magic bytes checked (blocks `
