logo
x
blog
Admin 7 months ago

Filament PHP : A Modern Admin Panel and Form Builder for Laravel

FilamentPHP is a sophisticated toolkit that empowers Laravel developers to create stunning admin panels and intricate forms with ease. This document explores the features and benefits of FilamentPHP, highlighting its elegant design and efficiency in reducing boilerplate code, ultimately streamlining the development process.

πŸš€ What is FilamentPHP?

FilamentPHP is a modern Laravel package that provides:

  • An Admin Panel with a clean, responsive UI.

  • A Form Builder and Table Builder for CRUD operations.

  • Powerful custom widgets, filters, relations, bulk actions, and more.

  • Extensions and plugins like Filament Spatie Media Library, Filament Shield, and Filament Charts.

It’s often compared to Laravel Nova, but Filament stands out due to its open-source nature, lightweight feel, and customizability.

βš™οΈ Why Use FilamentPHP?

  • 🧠 Developer-Centric: Built with Laravel devs in mind. You write PHP, not JS.

  • 🎨 Beautiful UI: Clean TailwindCSS-based interfaces that look modern out of the box.

  • 🧩 Modular Architecture: Extendable and customizable with ease.

  • πŸšͺ Built-in Auth: Comes with Laravel authentication and permissions support.

    1. Install via Composer

      πŸ“ˆ Real-time Insights: Use widgets, stats, and charts to visualize data.

      πŸ› οΈ Installing FilamentPHP

      Here’s how you can get started:

       

  •  
    composer require filament/filament
    1. Publish Filament Assets & Config

     
     
    php artisan filament:install
    1. Create Your First Admin Panel Resource

     
     
    php artisan make:filament-resource Product

    This will scaffold:

    • Model-based forms (Create/Edit)

    • Data table views (Index)

    • Navigation for the admin panel


    🧩 Core Components

    πŸ“‹ Resources

    Define CRUD operations using Resource classes. Example:

    class ProductResource extends Resource
    {
        public static function form(Form $form): Form
        {
            return $form->schema([
                TextInput::make('name')->required(),
                TextInput::make('price')->numeric(),
            ]);
        }

        public static function table(Table $table): Table
        {
            return $table->columns([
                TextColumn::make('name')->searchable(),
                TextColumn::make('price')->sortable(),
            ]);
        }
    }

    πŸ“Š Widgets

    Want a dashboard showing statistics? Use widgets.

    class StatsOverview extends Widget
    {
        protected function getStats(): array
        {
            return [
                Stat::make('Total Sales', '$20,000'),
                Stat::make('Users', '1,250'),
            ];
        }
    }

    πŸ” User Roles & Permissions

    Using plugins like Filament Shield, you can integrate role-based permissions with packages like Spatie Laravel-Permission, giving you fine-grained control over access.


    πŸ”Œ Useful Plugins

    • 🧷 Filament Forms: Build dynamic forms quickly.

    • πŸ–ΌοΈ Media Library: File uploads using Spatie.

    • πŸ—ΊοΈ Pages: Create custom standalone pages.

    • πŸ“ˆ Charts: Beautiful data visualizations.

    • πŸ”’ Shield: Roles & permissions made easy.


    πŸ“¦ Real-World Use Cases

    • Inventory or order management dashboards

    • Educational portals

    • Content Management Systems

    • Clinic or hospital backend systems

    • Custom CRM software

πŸ“š Resources