Installation:
composer require tomatophp/filament-browser
Publish the package assets and config:
php artisan vendor:publish --provider="TomatoPHP\FilamentBrowser\FilamentBrowserServiceProvider"
Register the Plugin:
Add to app/Providers/Filament/AdminPanelProvider.php:
public function panel(Panel $panel): Panel
{
return $panel
->id('admin')
->plugins([
\TomatoPHP\FilamentBrowser\FilamentBrowserPlugin::make(),
]);
}
First Use Case:
Access the browser via the Filament admin panel (default path: /admin/browser). Navigate to your project’s root directory (e.g., /storage/app or /public) to browse, edit, or manage files.
config/filament-browser.php to restrict access to sensitive directories (e.g., storage/logs, bootstrap/cache).
'disallowed_directories' => [
'storage/logs',
'bootstrap/cache',
],
'allowed_directories' => [
'storage/app',
'public',
],
.env files or deployment scripts before running php artisan deploy.resources/views) in the browser for quick access.storage/app/public and symlink them to public/storage.spatie/laravel-permission and revoke afterward.Custom File Types:
Extend the package to support custom file icons or actions (e.g., for .env files):
FilamentBrowser::registerFileType('env', '🌍', function ($file) {
return view('filament-browser::custom.env-actions', ['file' => $file]);
});
Event Listeners: Listen for file changes to trigger notifications or backups:
FilamentBrowser::listen('file.updated', function ($file) {
Log::info("File updated: {$file->path()}");
});
Monaco Editor Extensions: Add language support or themes by extending the editor config:
// resources/js/filament-browser.js
monaco.editor.defineTheme('dark-plus', { ... });
Security Risks:
Gate::define('access-filament-browser', function ($user) {
return $user->isSuperAdmin();
});
Performance:
storage/app/public with thousands of files) may lag.Filesystem::allFiles() with pagination.File Permissions:
storage/ owned by www-data).chown -R www-data:www-data storage/
chmod -R 775 storage/
Editor Conflicts:
Logs:
Enable debug mode in config/filament-browser.php:
'debug' => env('FILAMENT_BROWSER_DEBUG', false),
Check storage/logs/filament-browser.log for errors.
Common Errors:
disallowed_directories and Filament permissions.php artisan filament:cache-reset
allowed_directories are absolute (e.g., /var/www/html/storage/app).Keyboard Shortcuts:
Use Ctrl+P for search, Ctrl+N to create a new file, and F2 to rename files.
Markdown Preview:
Enable live preview for Markdown files by adding this to your filament-browser.js:
document.addEventListener('filament-browser-ready', () => {
const preview = document.getElementById('markdown-preview');
if (preview) preview.style.display = 'block';
});
Backup Integration: Automate backups of edited files using Laravel Scheduler:
// app/Console/Kernel.php
$schedule->command('filament-browser:backup')->daily();
Custom Actions: Add a "Download" button for files:
FilamentBrowser::registerFileAction('download', '📥 Download', function ($file) {
return redirect()->to($file->path());
});
Multi-Tenancy: For SaaS apps, scope the browser to the current tenant’s storage:
FilamentBrowser::scopeDirectories(function () {
return [tenantStoragePath()];
});
How can I help you explore Laravel packages today?