A Filament plugin that adds a file picker button to the RichEditor toolbar, powered by Livewire Filemanager.
Users can browse, search, and insert files directly from the RichEditor. Images are inserted as <img> tags, other files as download links.
- PHP 8.2+
- Filament 4.x or 5.x
- livewire-filemanager/filemanager ^1.0 (with API enabled)
- Laravel Sanctum (the filemanager API uses
auth:sanctum)
composer require livewire-filemanager/filament-pluginThe service provider is auto-discovered. No manual registration needed.
The filemanager API routes are protected by the auth:sanctum guard. If Sanctum is not already installed in your project:
composer require laravel/sanctum
php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider"
php artisan migrateNote: Filament uses cookie-based session authentication. Sanctum's stateful authentication works out of the box with Filament sessions — no API tokens needed. Just make sure your domain is listed in
SANCTUM_STATEFUL_DOMAINSin your.envif you're using a custom domain:SANCTUM_STATEFUL_DOMAINS=filament.test
php artisan vendor:publish --tag=filemanager-filament-configThis creates config/filemanager-filament.php:
return [
'api_url' => env('FILEMANAGER_API_URL', '/api/filemanager/v1'),
'lang' => env('FILEMANAGER_LANG', 'en'),
'toolbar_label' => 'Files',
];use LivewireFilemanager\Filament\FilemanagerPlugin;
class AdminPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
// ...
->plugins([
FilemanagerPlugin::make(),
]);
}
}use LivewireFilemanager\Filament\FilemanagerPlugin;
RichEditor::make('content')
->plugins([
FilemanagerPlugin::make(),
])A "Files" button appears in the toolbar. Clicking it (or pressing Ctrl+Shift+F / Cmd+Shift+F) opens the file browser modal.
You can also add a dedicated filemanager page to your panel. Create a Filament page:
// app/Filament/Pages/Filemanager.php
<?php
namespace App\Filament\Pages;
use BackedEnum;
use Filament\Pages\Page;
use Filament\Support\Icons\Heroicon;
class Filemanager extends Page
{
protected string $view = 'filament.pages.filemanager';
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedFolderOpen;
protected static ?string $navigationLabel = 'Filemanager';
protected static ?string $title = 'Filemanager';
protected static ?string $slug = 'filemanager';
}Then create the Blade view:
{{-- resources/views/filament/pages/filemanager.blade.php --}}
@push('styles')
@filemanagerStyles
@endpush
@push('scripts')
@filemanagerScripts
@endpush
<x-filament-panels::page>
<div class="h-[calc(100vh-12rem)] rounded-xl overflow-hidden border border-gray-200 dark:border-gray-700">
<livewire:livewire-filemanager />
</div>
</x-filament-panels::page>Note:
@filemanagerStylesloads Tailwind via CDN, which is fine for development. For production, create a custom Filament theme and add the package views to the Tailwind content scan:/* Tailwind v4 (resources/css/filament/admin/theme.css) */ @source '../../../../vendor/livewire-filemanager/filemanager/resources/views/**/*.blade.php';// Tailwind v3 (tailwind.config.js) content: [ './vendor/livewire-filemanager/filemanager/resources/views/**/*.blade.php', ]
The filemanager API uses auth:sanctum. Since Filament authenticates via cookies (session-based), you need to configure Sanctum for stateful requests.
1. Set your domain in .env:
SESSION_DOMAIN=filament.test
SANCTUM_STATEFUL_DOMAINS=filament.test2. Use the web middleware for API routes so session cookies are processed.
Publish the filemanager config if not already done:
php artisan vendor:publish --tag=livewire-filemanager-configThen in config/livewire-filemanager.php, change api to web:
'api' => [
'enabled' => true,
'middleware' => ['web', 'auth:sanctum'], // 'web' instead of 'api'
// ...
],Why
webinstead ofapi? Filament uses session-based authentication. Theapimiddleware group doesn't process session cookies, so Sanctum can't identify the logged-in user. Switching towebensures the session cookie is read and the user is authenticated transparently.
| Key | Env var | Default | Description |
|---|---|---|---|
api_url |
FILEMANAGER_API_URL |
/api/filemanager/v1 |
Filemanager API endpoint |
lang |
FILEMANAGER_LANG |
en |
Modal language (en, fr, es, it, nl, pt_BR, pt_PT, ro, tr, ar, fa, he) |
toolbar_label |
- | Files |
Toolbar button label |
FilemanagerPlugin::make()
->apiUrl('/custom/api/endpoint')
->lang('fr')
->toolbarLabel('Fichiers')FilemanagerPlugin::boot()
-> FilamentAsset::registerScriptData() # injects apiUrl + lang into window.filamentData
-> getTipTapJsExtensions() # registers the JS bundle URL
RichEditor loads the extension via dynamic import()
-> export default factory function # reads window.filamentData
-> Filemanager.configure({ apiUrl, lang }) # configures the TipTap extension
User clicks toolbar button
-> editor().commands.openFilemanager() # opens the modal
-> modal fetches files from API # browse, search, select
-> inserts <img> or <a> into editor # done
Laravel Sanctum is not installed. See the installation steps above.
Make sure the plugin is registered in both places:
- In
AdminPanelProvidervia->plugins([FilemanagerPlugin::make()]) - On the
RichEditorfield via->plugins([FilemanagerPlugin::make()])
The filemanager API uses auth:sanctum with session cookies. Ensure:
- Your domain is in
SANCTUM_STATEFUL_DOMAINSin.env SESSION_DOMAINis set to your domain in.env- The filemanager API middleware is set to
['web', 'auth:sanctum'](not['api', ...]) — see Sanctum & session configuration - The user is logged into Filament
The backend package livewire-filemanager/filemanager must be installed and configured:
composer require livewire-filemanager/filemanager
php artisan vendor:publish --tag=livewire-filemanager-config
php artisan vendor:publish --tag=livewire-filemanager-migrations
php artisan migrateMake sure the API is enabled in config/livewire-filemanager.php:
'api' => [
'enabled' => true,
'middleware' => ['web', 'auth:sanctum'],
],The Livewire filemanager uses Tailwind utility classes. If styles are missing, add @filemanagerStyles to inject the Tailwind CDN (dev only), or set up a custom Filament theme that scans the package views.
Add @filemanagerScripts to your page view — it loads the @alpinejs/ui plugin required by the filemanager's dialog and popover components.
npm install
npm run buildThis bundles resources/js/src/index.ts into resources/js/dist/filemanager.js using esbuild.
composer install
vendor/bin/pestMIT