How to Install Filament to Laravel 12: Step-by-Step Guide

How to Install Filament to Laravel 12: Step-by-Step Guide

Filament is a modern admin panel builder that works seamlessly with Laravel 12. It helps developers spin up powerful management interfaces fast.

How to install Filament on Laravel 12 -> you just need a couple of commands: run composer require filament/filament, execute php artisan filament:install --panels, and create an admin user with php artisan make:filament-user.

The whole process only takes a few minutes. You’ll end up with a working admin panel at the /admin route—pretty slick.

image 6

Laravel 12 brings better performance and new features that pair nicely with Filament’s no-code admin panel builder. You can build CRUD systems, manage records, and tweak the admin interface with barely any code.

The framework handles authentication, forms, tables, and notifications for you. That’s a lot of heavy lifting off your plate.

This guide takes you through the full installation process, from starting a fresh Laravel 12 project to installing Filament and configuring access. We’ll also look at creating resources for database management.

Along the way, you’ll get tips for production optimization and a quick peek at advanced features like multi-tenancy and role management.

Key Takeaways

  • Install Filament in Laravel 12 using Composer and the filament:install command to get a working admin panel in minutes
  • Configure user authentication and access control to secure the admin panel
  • Optimize performance with caching, and customize resources to build robust database management interfaces

Prerequisites for Installing Filament on Laravel 12

image 7

You’ll need certain software versions and a configured environment to install Filament on Laravel 12. Make sure you have PHP 8.1 or higher, Composer for dependencies, a working Laravel 12 project, and Node.js with npm for assets.

Required PHP and Composer Versions

Filament needs PHP 8.1 or above. Run php -v in your terminal to check.

If you’re running anything older, you’ll need to upgrade first.

Composer is the dependency manager for PHP projects. Make sure it’s installed globally. Check with composer --version.

Most modern dev tools—XAMPP, Laragon, Laravel Herd—let you manage PHP versions easily. If you’re stuck on an old PHP version, update via your system’s package manager or dev tool settings.

Laravel Project Preparation

A fresh Laravel 12 install is the cleanest way to start. Run composer create-project laravel/laravel and give your project a name.

This pulls down Laravel and sets up the basic structure. If you’ve already got a Laravel 12 project, that’s fine too.

Just make sure dependencies are installed and your .env file has the right database credentials. Run composer install if you’re unsure.

If you’re starting from scratch, generate the application key with php artisan key:generate. Laravel 12 handles service providers a bit differently—now they’re in bootstrap/providers.php instead of config/app.php.

Database Setup Options

Filament supports MySQL, PostgreSQL, and SQLite. MySQL is still the go-to for production, but you can use whatever fits.

Create your database and update .env with DB_DATABASE, DB_USERNAME, and DB_PASSWORD.

For quick dev work, SQLite is super simple. Set DB_CONNECTION=sqlite and create an empty file at database/database.sqlite.

Database TypeBest ForSetup Complexity
MySQLProduction appsMedium
PostgreSQLAdvanced featuresMedium
SQLiteTesting/developmentLow

Make sure your database is accessible before running migrations. Try php artisan migrate to check the connection.

Essential Node.js and NPM Setup

Node.js and npm handle frontend asset compilation, even though Filament is mostly backend. You’ll need Node.js 16 or higher.

Check with node -v and npm -v. Npm installs JavaScript dependencies from package.json.

Laravel 12 uses Vite for asset bundling, which relies on Node.js. After installing Node.js, run npm install in your project folder.

This pulls in all the JavaScript packages. Use npm run dev for development assets, and npm run build for production builds.

Creating a New Laravel 12 Application

Laravel 12 needs PHP 8.2 or higher. You can set up a new project in two main ways.

Both methods give you a ready-to-go project with all dependencies and config files in place.

Using the Laravel Installer

The Laravel installer is the fastest way to start new projects. First, install the CLI tool globally with composer global require laravel/installer.

Once that’s done, run laravel new blog-project. This creates a fresh Laravel 12 app in a folder called blog-project.

The installer downloads everything you need and sets up the structure. You can pick starter kits like Breeze or Jetstream, which come with authentication and support for React, Vue, or Livewire with Tailwind CSS.

Setting Up with Composer

If you don’t want the Laravel installer, just use composer create-project. This grabs Laravel straight from the Composer repo.

Run composer create-project laravel/laravel blog-project. Composer handles the rest.

This approach works everywhere and only needs Composer installed. The structure is the same as the installer, but you won’t get the interactive starter kit options.

Environment Configuration

After install, you’ll find a .env file with your app’s settings. Laravel generates this by default. Update these values for your local setup.

Database credentials are the most important. Set DB_CONNECTION, DB_HOST, DB_DATABASE, DB_USERNAME, and DB_PASSWORD so your app can talk to the database.

If the app key is missing, run php artisan key:generate. The key encrypts session data and other sensitive info. Without it, Laravel won’t run securely.

Installing Filament Package

To install Filament, run two main commands: one with Composer to download the package, and one with Artisan to set up the panel builder.

Laravel usually registers the service provider automatically, but it’s worth double-checking.

Running Composer Require for Filament

Start by installing Filament with Composer: composer require filament/filament:"^3.3" -W in your project directory.

This command downloads Filament and its dependencies. The -W flag updates dependencies if needed, and "^3.3" grabs the latest compatible version.

When you run this, Composer pulls in several Filament packages at once—Form Builder, Table Builder, Notifications, Actions, Infolists, and Widgets. No need to install them separately.

Installing Filament Panels via Artisan Command

Next, run php artisan filament:install --panels in your terminal. This sets up the panel builder system for your admin interface.

The --panels flag adds the panel builder features. It creates an AdminPanelProvider.php file in app/Providers/Filament.

This file holds your admin panel’s configuration—panel path, authentication, the whole lot. The command tries to register this provider automatically with Laravel’s container.

Verifying and Registering Service Providers

Laravel 11+ stores service providers in bootstrap/providers.php; Laravel 10 uses config/app.php. Check the right file to see if AdminPanelProvider is listed.

If it’s missing, you’ll need to add App\Providers\Filament\AdminPanelProvider::class manually to the providers array in bootstrap/providers.php (for Laravel 12).

If you skip this, /admin will throw an error. Double-checking now saves you headaches later.

Once that’s sorted, Filament’s panel system is ready for admin user creation and resource building.

Database Migration and User Creation

After installing Filament, you need to set up the database structure and create admin users for panel access.

Laravel uses migrations for database tables, and Filament gives you commands to create users with panel permissions.

Migrating Database Tables

Laravel migrations let you define your database structure in code. When you run php artisan migrate, it executes pending migration files and creates tables in your database.

This command builds tables like users, password resets, and any custom tables you set up. It reads migration files from the database/migrations directory.

Each migration file contains instructions for creating or changing tables. When you run Laravel 12 migrations, it keeps track of which migrations have already run, so nothing gets duplicated.

Developers should run the migrate command after setting up the database connection in the .env file. The process only takes a few seconds and shows each table as it gets created.

If something goes wrong, it’s usually a problem with database credentials or maybe the tables already exist.

Creating an Initial Admin User

Filament needs at least one user account to access the admin panel. The php artisan make command helps you create an admin user with an interactive prompt.

It asks for a name, email, and password. This command specifically creates users with the right permissions for Filament access, which is different from the standard Laravel user creation.

You pick the email you’ll use to log in to the admin panel. The password has to meet any validation rules set in your User model.

Once you finish, the new admin can log in to the Filament dashboard right away.

Seeding Additional Users

Manually creating lots of users for testing gets old fast. Laravel’s factory system can automate this with User::factory()->create().

This method generates fake user data based on definitions inside the database/factories directory. You can create one user or a bunch at once.

Developers can override default values by passing attributes, like User::factory()->create(['email' => '[email protected]']) for a specific email.

Seeders organize these factory calls so you get consistent test data. Running php artisan db executes all seeder classes and fills your tables with sample records.

This is great for development, but please—don’t run it on production databases.

Configuring User Access and Authentication

Filament needs certain security configurations to control who gets into the admin panel. By default, any user can log in locally, but in production you’ll want to define access rules in your User model.

Implementing FilamentUser in User Model

The User model has to implement the FilamentUser interface for Filament’s authentication to work. Add these imports at the top of app/models/user.php: use Filament\Models\Contracts\FilamentUser; and use Filament\Panel;.

Change the class declaration to class User extends Authenticatable implements FilamentUser. This tells Filament your User model will handle panel access control.

If you skip this, users will hit a 403 error trying to access the admin panel in production. The FilamentUser implementation acts as a contract between Laravel’s authentication and Filament’s access control.

Defining canAccessPanel Method

The canAccessPanel method decides which users can use specific Filament panels. It takes a Panel object and returns true or false.

A simple way is to check for an is_admin flag: public function canAccessPanel(Panel $panel): bool { return $this->is_admin == 1; }. That way, only admins get in.

For more complex apps, you might use role-based access control or check panel IDs. If you’re building multi-panel systems, each panel can have its own rules based on user roles or permissions.

Integrating Authentication Starter Kits

Laravel Breeze and other starter kits work fine with Filament’s authentication. You can install Breeze before or after Filament—no big deal.

Filament gives you its own authentication pages through the AdminPanelProvider config. Add ->registration(), ->passwordReset(), and ->emailVerification() to enable those features without needing a separate starter kit.

For quick testing, you can make admin users with php artisan tinker and run User::factory()->create(['is_admin' => 1]). It’s a fast way to create test users during development without poking around in the database.

Accessing and Customizing the Filament Admin Panel

Once Filament is installed, you’ll want to access the admin interface and tweak it to fit your app. The admin dashboard gives you instant access to panel management, and you can adjust themes and layouts using Tailwind and Livewire v3.

Serving the Laravel Application

Start the local dev server by running php artisan serve in your terminal. The app launches on http://localhost:8000 by default.

To get into the Filament admin panel, go to /admin in your browser. So, http://localhost:8000/admin. You’ll see a login screen—sign in with the credentials you set up during make.

Once you log in, the admin interface loads. Filament runs on Livewire v3, so interactions happen without full page reloads.

Navigating the Filament Admin Interface

The Filament dashboard shows a clean sidebar navigation on the left. The main area displays widgets, stats, and quick actions for your app.

Your resources, custom pages, and settings are all in the sidebar menu. Each item links to a management section. Up top, there’s a navigation bar with user profile options and logout.

The dashboard lists all registered resources and pages. You can click around to manage database records. Styling comes from Tailwind CSS, so the design looks modern and works on any device.

Customizing Theme and Layout

To customize the admin panel, edit AdminPanelProvider.php in app/Providers/Filament/. This file handles theme colors, navigation position, and branding.

Add custom colors using the colors() method:

->colors([
    'primary' => '#3b82f6',
])

Change navigation position with the navigation() method. You can switch between sidebar or top bar layouts. Add a custom logo using brandLogo() and update the favicon with favicon().

Filament supports dark mode by default. You can turn it off or force a specific mode in the config. All the customizations use Tailwind utility classes for a consistent look.

Creating and Managing Filament Resources

Filament resources connect your database models to the admin panel with automated forms and tables. First, generate models with migrations, then create Filament resources to define how data shows up and works in the panel.

Generating New Models and Migrations

Laravel needs a model and table before you make a Filament resource. Use php artisan make:model with the migration flag to generate both.

For example, php artisan make:model Post -m creates a Post model and a migration file. The -m flag sets up the basic table structure.

Open the migration file and define table columns—maybe title, content, and published_at for a blog post. Set data types like string(), text(), or timestamp().

After setting up columns, run php artisan migrate to create the table. In your model, specify fillable properties or relationships as needed.

Creating Filament Resources

Use php artisan make:filament-resource to generate a resource with all the files you need. This command creates a resource class, form schema, table schema, and pages for viewing and editing records.

For the Post model, run php artisan make:filament-resource Post --generate. This creates a resource in app/Filament/Resources/PostResource.php. The --generate flag builds form fields and table columns based on your model’s database structure.

The resource file has two main methods: form() and table(). These control how data appears in forms and lists.

Managing Forms and Tables

The form builder in Filament resources uses a schema array to define input fields. Each field type matches a data input—like TextInput::make('title') for text or Textarea::make('content') for longer entries.

Common form field types include:

  • TextInput – Single-line text fields
  • Textarea – Multi-line text areas
  • Select – Dropdown menus
  • Toggle – Boolean switches
  • DatePicker – Date pickers

Tables show data in columns using the table() method. Add columns with TextColumn::make('title') to display database fields. Tables support sorting, searching, and filtering—just chain methods like ->sortable() or ->searchable() onto the columns.

The form builder handles validation and saving automatically. You can customize validation rules by adding ->required() or ->maxLength(255) to fields in the schema.

Advanced Features: Panels, Multi-Tenancy, and Role Management

Filament supports multiple admin panels in one Laravel app, so you can make separate interfaces for different user groups. Multi-tenancy lets SaaS apps keep data isolated between organizations, and role management controls what users can do.

Setting Up Additional Filament Panels

Create extra Filament panels by running php artisan make:filament-panel. This generates a new panel provider in app/Providers/Filament. Each panel gets its own URL, authentication, and resources.

It’s common to make separate panels for admins and customers. Maybe the admin panel is at /admin and the customer portal is at /app. Each panel can have its own theme, navigation, and access controls.

Configure the new panel by editing the panel provider—set the panel ID, path, and login route. Register resources to specific panels by naming them in the resource config. This keeps your user interfaces organized and manageable.

Implementing Multi-Tenancy Architecture

Building a Laravel Filament multi-tenant panel means setting up tenant models and making the app tenant-aware. Multi-tenancy lets SaaS apps serve several organizations from one codebase, keeping each organization’s data separate.

Filament comes with built-in support for tenant-scoped resources. Developers set the tenant model in the panel provider and add the HasTenants interface to the User model.

The framework filters queries so users only see data for their current tenant. Each tenant usually stands for an organization or company.

Users can switch tenants if they belong to more than one. The panel provider manages tenant switching and makes sure users only get into tenants they’re allowed to view.

Enabling Role and Permission Control

Managing Laravel Filament Spatie permissions on multi-tenant panels lets you control access in detail. The Spatie Laravel Permission package works smoothly with Filament to limit who can view, create, edit, or delete resources.

Developers set up roles like “admin,” “editor,” and “viewer” with matching permissions. Filament checks these permissions before showing navigation or letting users take actions.

The canViewAny(), canCreate(), canEdit(), and canDelete() methods handle access at the resource level. In multi-tenant apps, permissions can be tied to specific tenants.

So a user might be an admin in one company but just a viewer in another. Mixing panels, tenancy, and roles gives you a powerful and secure admin system for complex Laravel projects.

Optimizing and Deploying Filament for Production

To deploy for production, you’ll need to cache components and icons and tweak some PHP settings for speed. Running php artisan filament:optimize bundles several caching steps, and OPcache speeds up PHP across your app.

Caching Filament Components and Blade Icons

Filament has a one-liner for caching components and Blade Icons. Just run php artisan filament:optimize in your deployment script—it writes cache files to bootstrap/cache/filament and caches all panel icons.

This command does what php artisan filament:cache-components and php artisan icons:cache do, but faster. Caching helps a lot if your app has tons of resources, pages, widgets, or relation managers because it cuts down file scanning during auto-discovery.

Skip these caching commands during local development. Cached components can hide new files until you clear the cache. Use php artisan filament:optimize-clear to wipe all Filament caches when you need a fresh start.

Enabling OPcache for Performance

OPcache keeps compiled PHP code in memory, so PHP doesn’t have to recompile files on every request. You can check if OPcache is on by running php -r "echo 'opcache.enable => ' . ini_get('opcache.enable') . PHP_EOL;" in your terminal.

If you see opcache.enable => 1, you’re good. If not, add opcache.enable=1 to your php.ini to turn it on.

This setting works for all PHP apps on your server, not just Filament. Hosting environments handle OPcache differently—shared hosts usually have it on, but VPS or dedicated servers might need you to set it up yourself.

Production Environment Optimizations

Always run Laravel’s php artisan optimize during deployment. This caches config and routes, so your app doesn’t waste time loading and parsing files on every request.

The composer.json file comes with php artisan filament:upgrade in the post-autoload-dump script by default. That keeps assets up to date after Composer updates.

If you remove that script, you might end up with missing or outdated assets in production. Production deployments need user authorization if APP_ENV isn’t set to local.

Without proper authorization using the FilamentUser interface, nobody can get into the panel in production.

Frequently Asked Questions

Setting up Filament in Laravel 12 means having your system ready and knowing the basic steps. People run into some common issues with installation, updates, and plugins, and it’s good to know how to fix them.

What are the prerequisites for installing Filament in a Laravel 12 project?

You’ll need PHP 8.2 or newer for Laravel 12. Composer has to be installed to manage your PHP packages.

Node.js and NPM are required for compiling frontend assets. Make sure your Laravel app runs without errors before adding Filament.

Set up your database connection in Laravel first. Run php artisan serve to check everything works before you start with Filament.

How can you troubleshoot common errors during the Filament installation process?

Missing dependencies cause lots of install headaches. Run composer install to pull in all needed packages before installing Filament.

Permission errors happen if Laravel can’t write to storage directories. Try chmod -R 775 storage bootstrap/cache to fix that.

If asset compilation fails, it’s usually missing NPM packages. Run npm install and then npm run dev to build frontend assets.

Cache issues can be sneaky. Clearing with php artisan cache:clear and php artisan config:clear often does the trick.

What are the steps to properly configure the Filament admin panel in Laravel?

Start by running php artisan filament:install --panels. That sets up the admin panel’s structure and config files.

Next, create a Filament user with php artisan make:filament-user. You’ll enter name, email, and password.

Edit config/filament.php to tweak panel settings. You can change the admin path, middleware, and authentication options here.

Then run php artisan filament:assets to publish panel assets. Wrap up with npm run dev to build frontend resources.

How do you update Filament to its latest version in a Laravel application?

To update, run composer update filament/filament in your project folder. That grabs the latest compatible version per your composer.json.

Check the changelog before updating so you don’t get blindsided by breaking changes. Major upgrades might need you to adjust some code.

After updating, run php artisan filament:upgrade for any needed migrations or config changes. Clear the cache with php artisan optimize:clear so the app uses the new version.

Test the admin panel after updating. Double-check your custom resources and pages for anything that broke or needs updating.

Can you uninstall Filament from a Laravel project and what is the proper procedure?

To remove Filament, run composer remove filament/filament. That deletes the package and its dependencies.

Delete any Filament files you added, like the app/Filament directory and your custom resources. Remove config/filament.php manually too.

Take out Filament references from your layouts and routes. If you used Filament migrations, roll those back to drop the tables.

Finally, run npm run dev to make sure you don’t have broken asset references left in your build.

What is the process for integrating Filament plugins into a Laravel 12 project?

Start by running the Composer require command for the plugin you want. Make sure you enter the exact package name—it’s easy to mistype.

After installation, most plugins need a setup command to finish things up. The Filament docs have installation commands for each official plugin, so it’s worth double-checking there.

You’ll usually want to tweak the plugin’s configuration files. To do that, publish them using php artisan vendor:publish and the right tag for your plugin.

Certain plugins also need extra frontend assets. Just run npm install and npm run dev, and that should pull in the JavaScript and CSS you need for the admin panel.

Share this article:
As a passionate DevOps Engineer, I thrive on bridging the gap between development and operations. My expertise lies in crafting efficient, scalable infrastructure solutions, with a particular fondness for Linux and Ubuntu environments. I'm constantly exploring innovative ways to streamline processes, enhance system reliability, and boost productivity through automation. My toolkit includes a wide array of cutting-edge technologies and best practices in continuous integration, deployment, and monitoring. When I'm not immersed in code or fine-tuning server configurations, you'll find me staying up-to-date with the latest industry trends and sharing knowledge with the tech community. Let's connect and discuss how we can revolutionize your infrastructure!