Kritim Yantra
Feb 28, 2025
AdminLTE is a popular open-source admin dashboard template built with Bootstrap, offering a sleek, responsive, and customizable interface for creating admin panels, dashboards, and backend systems. Integrating AdminLTE into your Laravel 12 project can accelerate development by providing pre-built components and a polished design right out of the box.
In this blog post, I’ll guide you through the process of integrating AdminLTE into a Laravel 12 application. Whether you’re building a simple admin panel or a sophisticated dashboard, this tutorial will get you up and running quickly.
AdminLTE is a free, open-source admin dashboard template based on Bootstrap 4. It comes packed with features like:
Pairing AdminLTE with Laravel allows you to focus on your application’s logic rather than designing an admin interface from scratch.
Laravel 12, the latest version of the Laravel framework at the time of writing, brings improved performance, new features, and enhanced security. Combining it with AdminLTE provides:
First, ensure you have Composer installed, then create a new Laravel 12 project:
composer create-project --prefer-dist laravel/laravel adminlte-laravel "12.*"
Navigate to your project directory:
cd adminlte-laravel
The easiest way to integrate AdminLTE into Laravel is by using the jeroennoten/laravel-adminlte
package, which streamlines the process. Install it via Composer:
composer require jeroennoten/laravel-adminlte
Next, publish the AdminLTE assets to your project:
php artisan adminlte:install
This command does the following:
resources/views/vendor/adminlte
.config/adminlte.php
.AdminLTE relies on a specific layout structure. The adminlte:install
command provides a master layout file at resources/views/vendor/adminlte/master.blade.php
. You can use this as the foundation for your admin pages.
Create a new view for your dashboard at resources/views/admin/dashboard.blade.php
:
@extends('adminlte::master')
@section('adminlte_css')
@parent
<!-- Add custom CSS here if needed -->
@stop
@section('body')
<div class="content-wrapper">
<section class="content-header">
<h1>Dashboard</h1>
</section>
<section class="content">
<p>Welcome to the admin dashboard!</p>
</section>
</div>
@stop
@section('adminlte_js')
@parent
<!-- Add custom JS here if needed -->
@stop
The sidebar menu is managed in config/adminlte.php
. Open the file and customize the menu array. For example, add a "Dashboard" link:
'menu' => [
[
'text' => 'Dashboard',
'url' => 'admin/dashboard',
'icon' => 'fas fa-tachometer-alt',
],
// Add more menu items here
],
Ensure you define corresponding routes and controllers for each menu item.
AdminLTE supports various color schemes. Modify the skin option in config/adminlte.php
to change the theme:
'skin' => 'skin-blue',
Options include skin-blue
, skin-purple
, skin-green
, and more.
Generate a controller for the dashboard:
php artisan make:controller Admin/DashboardController
Edit app/Http/Controllers/Admin/DashboardController.php
to include a method for displaying the dashboard:
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
class DashboardController extends Controller
{
public function index()
{
return view('admin.dashboard');
}
}
In routes/web.php
, add a route for the dashboard:
Route::get('admin/dashboard', [App\Http\Controllers\Admin\DashboardController::class, 'index'])->name('admin.dashboard');
To restrict access (e.g., to authenticated users), apply middleware:
Route::get('admin/dashboard', [App\Http\Controllers\Admin\DashboardController::class, 'index'])
->middleware('auth')
->name('admin.dashboard');
For custom styling or scripts, use the @section('adminlte_css')
and @section('adminlte_js')
directives in your views. For example, to add a custom CSS file:
@section('adminlte_css')
@parent
<link rel="stylesheet" href="{{ asset('css/admin-custom.css') }}">
@stop
Place the admin-custom.css
file in public/css
and create it as needed.
Launch the Laravel development server:
php artisan serve
Visit http://localhost:8000/admin/dashboard
(or your defined route) in your browser. If you’ve set up authentication, log in to access the page. You should see the AdminLTE dashboard with your custom content.
php artisan storage:link
if you’re using storage for assets, or verify that public assets are correctly placed.npm install
and npm run dev
to compile frontend assets.auth
, admin
) to restrict admin routes to authorized users.config/adminlte.php
.Integrating AdminLTE into Laravel 12 is a simple yet powerful way to enhance your admin panel’s design and functionality. By following these steps, you’ll have a fully operational, customizable admin interface ready for your project. Whether it’s a small app or a large-scale system, AdminLTE and Laravel 12 together offer a robust foundation for backend development.
Happy coding, and enjoy crafting your admin panel with AdminLTE and Laravel 12!
No comments yet. Be the first to comment!
Please log in to post a comment:
Continue with Google