Backend Development 7 min read

Getting Started with Filament: Installation, Configuration, and Demo for Laravel Backend Development

This guide introduces Filament, a full‑stack component library for Laravel, outlines its environment requirements, provides step‑by‑step installation and configuration commands, explains core components, and demonstrates a complete demo including models, migrations, relationships, forms, widgets, and charts.

Laravel Tech Community
Laravel Tech Community
Laravel Tech Community
Getting Started with Filament: Installation, Configuration, and Demo for Laravel Backend Development

Filament is a full‑stack component library designed for Laravel development, offering a lightweight cross‑platform real‑time rendering engine that accelerates UI creation without starting from scratch.

Environment requirements include PHP 8.1+, Laravel v10.0+, Livewire v3.0+, and Tailwind v3.0+ (or v4).

PHP 8.1+
Laravel v10.0+
Livewire v3.0+
Tailwind v3.0+ (or v4?)

Installation is performed on a Laravel 10+ project with the following commands:

composer require filament/filament:"^3.2" -W
php artisan filament:install --panels

Basic configuration includes creating a Filament user, clearing caches, and publishing configuration files:

php artisan make:filament-user
php artisan filament:optimize
# or php artisan filament:optimize-clear
php artisan vendor:publish --tag=filament-config

To allow panel access in production, implement FilamentUser and define canAccessPanel :

<?php
namespace App\Models;
use Filament\Models\Contracts\FilamentUser;
use Filament\Panel;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable implements FilamentUser {
    public function canAccessPanel(Panel $panel): bool {
        return str_ends_with($this->email, '@yourdomain.com') && $this->hasVerifiedEmail();
    }
}

Core components pre‑installed with Filament include Form Builder, Table Builder, Notification Builder, Action, Infolist, and Widget packages. Additional components can be installed via Composer, for example:

# Install Form Builder
composer require filament/forms:"^3.2" -W

# Install Table Builder
composer require filament/tables:"^3.2" -W

# Install Notification Builder
composer require filament/notifications:"^3.2" -W

# Install Action
composer require filament/actions:"^3.2" -W

# Install Infolist
composer require filament/infolists:"^3.2" -W

# Install Widgets
composer require filament/widgets:"^3.2" -W

Demo code showcases creating models, migrations, relationships, and Filament resources:

# Generate models
php artisan make:model Owner -m
php artisan make:model Patient -m
php artisan make:model Treatment -m

# Migration examples
Schema::create('owners', function (Blueprint $table) {
    $table->id();
    $table->string('email');
    $table->string('name');
    $table->string('phone');
    $table->timestamps();
});

Schema::create('patients', function (Blueprint $table) {
    $table->id();
    $table->date('date_of_birth');
    $table->string('name');
    $table->foreignId('owner_id')->constrained('owners')->cascadeOnDelete();
    $table->string('type');
    $table->timestamps();
});

Schema::create('treatments', function (Blueprint $table) {
    $table->id();
    $table->string('description');
    $table->text('notes')->nullable();
    $table->foreignId('patient_id')->constrained('patients')->cascadeOnDelete();
    $table->unsignedInteger('price')->nullable();
    $table->timestamps();
});

# Define relationships
class Owner extends Model {
    public function patients(): HasMany { return $this->hasMany(Patient::class); }
}
class Patient extends Model {
    public function owner(): BelongsTo { return $this->belongsTo(Owner::class); }
    public function treatments(): HasMany { return $this->hasMany(Treatment::class); }
}
class Treatment extends Model {
    public function patient(): BelongsTo { return $this->belongsTo(Patient::class); }
}

Form definitions use Filament's Form components, such as TextInput , Select , and DatePicker , with validation rules and option lists.

Stat and chart widgets can be generated via Artisan commands and customized to display counts of different patient types:

# Create stats widget
php artisan make:filament-widget PatientTypeOverview --stats-overview

# Create chart widget
php artisan make:filament-widget TreatmentsChart --chart

# Example widget class
<?php
namespace App\Filament\Widgets;
use App\Models\Patient;
use Filament\Widgets\StatsOverviewWidget as BaseWidget;
use Filament\Widgets\StatsOverviewWidget\Stat;

class PatientTypeOverview extends BaseWidget {
    protected function getCards(): array {
        return [
            Stat::make('Cats', Patient::query()->where('type', 'cat')->count()),
            Stat::make('Dogs', Patient::query()->where('type', 'dog')->count()),
            Stat::make('Rabbits', Patient::query()->where('type', 'rabbit')->count()),
        ];
    }
}

Conclusion : Filament streamlines backend interface development for Laravel applications, allowing developers to focus on business logic while providing a rich set of UI components and widgets. More information and demos are available on the official sites.

backend developmentFilamentPHPInstallationadmin panelDemoLaravel
Laravel Tech Community
Written by

Laravel Tech Community

Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.