Beginner's Guide: Configuring Filament in Laravel in 5 Minutes
Start by explaining what Filament is and why it’s worth trying out for Laravel developers. Here’s an outline:
• What is Filament? Filament is a lightweight admin panel and form builder designed specifically for Laravel applications. It simplifies creating admin dashboards and managing resources without needing to write much custom code.
• Why Use Filament? For anyone who needs a user-friendly backend to manage data and settings, Filament offers a fast, developer-friendly solution. It’s particularly valuable for creating CRUD interfaces, handling complex forms, and adding various widgets with minimal setup.
•What Will This Guide Cover? This post will guide readers through setting up Filament in Laravel from scratch in under five minutes, providing them with a functional admin panel they can build upon.
Set the Stage
Before diving into the steps, let’s quickly set up our environment to make sure everything runs smoothly.
• Docker & Laravel Sail
Instead of configuring a local web server manually, we’ll use Docker and Laravel Sail. This approach simplifies the setup, especially for developers working in different environments, as Docker ensures a consistent environment across all setups. Sail, Laravel’s official Docker environment, gives us a ready-to-go Laravel setup with just a few commands.
• Composer & Filament
Once our Laravel project is up and running with Sail, we’ll add Filament using Composer. This step is straightforward, thanks to Laravel’s package management. By the end, you’ll have a fully functional admin panel accessible through a single URL.
In the next steps, I’ll guide you through setting up a Laravel project with Docker and installing Filament—all in under five minutes!
Step 1: Creating a Laravel Project with Sail
1. Installing Laravel with Sail
Start by explaining how to set up a new Laravel project with Sail in a single command. Using curl, we’ll download and configure Laravel with Docker support:
curl -s "https://laravel.build/my-project" | bash
This command creates a new directory named project-name and sets up Laravel along with Docker containers needed for development, like MySQL, Redis, and others.
2. Navigating to the Project Directory
Once the project is set up, navigate to the project’s directory:
cd my-project
3. Starting Sail
To bring up the development environment, use the following command:
./vendor/bin/sail up
This command initializes the Docker containers, so your Laravel application will be available on http://127.0.0.1
4. Confirming Everything is Running
Once Sail has started, you can verify the setup by opening http://127.0.0.1 in your browser. You should see the default Laravel welcome page, confirming that Sail and Docker are up and running correctly.
This step-by-step guide will make it easy for readers to get a Laravel project running with Sail, creating a smooth foundation for the next steps with Filament.
Step 2: Installing Filament in Your Laravel Project
Now that we have our Laravel project running with Sail, let’s add Filament to get a basic admin panel up and running.
1. Installing Filament
We’ll use Composer to install Filament. In the project’s root directory, run the following command:
./vendor/bin/sail composer require filament/filament
This will download and install Filament, making it ready to be configured in our Laravel app.
Create Your First Filament Panel
./vendor/bin/sail artisan filament:install
2. Setting Up the Database
Since Filament requires a database connection, make sure your database is set up and that migrations have been run. In a new terminal, run:
./vendor/bin/sail artisan migrate
This will create all necessary tables for Laravel, including those needed for Filament’s authentication.
3. Creating Your First Admin User
Filament requires an admin user to log into the dashboard. You can create one with the following command:
./vendor/bin/sail artisan make:filament-user
This command will prompt you to enter the email, name, and password for your new admin user.
4. Accessing the Filament Admin Panel
Now, with your admin user created, open your browser and go to http://127.0.0.1/admin. Use the email and password you just set up to log in, and you’ll have access to the Filament admin dashboard.
This guide helps readers get Filament installed and configured quickly, leading to a fully functional admin panel that they can start exploring right away.
Subscribe to my newsletter
Read articles from Filipe Clemente directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by