#5- Setup Admin HTML themes (AdminLTE) | Laravel 10 E-Commerce
Table of Contents
Introduction
This tutorial will guide you through the process of setting up the AdminLTE HTML theme within a Laravel 10 e-commerce application. AdminLTE is a popular admin dashboard template that provides a clean and responsive design, making it ideal for managing your e-commerce system. By following these steps, you will integrate the AdminLTE theme into your Laravel project effectively.
Step 1: Install Laravel
Before integrating the AdminLTE theme, ensure you have Laravel installed. If you haven't set up a Laravel project yet, follow these instructions:
- Open your terminal.
- Navigate to the directory where you want to create your project.
- Run the following command to create a new Laravel project:
composer create-project --prefer-dist laravel/laravel your-project-name - Navigate into your project folder:
cd your-project-name
Step 2: Download AdminLTE
You need to download the AdminLTE theme to include it in your Laravel project.
- Visit the AdminLTE GitHub repository at AdminLTE GitHub.
- Click on the green "Code" button and select "Download ZIP."
- Extract the ZIP file to your computer.
Step 3: Add AdminLTE Files to Laravel
Now, you will copy the relevant AdminLTE files into your Laravel project.
- Open the extracted AdminLTE folder.
- Copy the
distfolder and thepluginsfolder from AdminLTE. - In your Laravel project, navigate to
publicdirectory. - Paste the
distandpluginsfolders into thepublicdirectory.
Step 4: Create Blade Layout
You need to create a layout file to use AdminLTE components in your views.
- In your Laravel project, navigate to
resources/views. - Create a new folder called
layouts. - Inside the
layoutsfolder, create a new file namedapp.blade.php. - Open
app.blade.phpand add the following code:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="{{ asset('dist/css/adminlte.min.css') }}"> <script src="{{ asset('plugins/jquery/jquery.min.js') }}"></script> <script src="{{ asset('dist/js/adminlte.min.js') }}"></script> <title>AdminLTE</title> </head> <body class="hold-transition sidebar-mini"> <div class="wrapper"> @yield('content') </div> </body> </html>
Step 5: Create a Sample View
To ensure that AdminLTE is working properly, create a sample view.
- In
resources/views, create a new file nameddashboard.blade.php. - Add the following code to
dashboard.blade.php:@extends('layouts.app') @section('content') <div class="content-wrapper"> <section class="content"> <h1>Welcome to AdminLTE Dashboard</h1> <p>This is a sample dashboard page.</p> </section> </div> @endsection
Step 6: Set Up Routes
You need to define a route to access the dashboard view you just created.
- Open
routes/web.php. - Add the following route:
Route::get('/dashboard', function () { return view('dashboard'); });
Step 7: Test the Setup
Now it's time to test your setup and see if everything works as expected.
- Start the Laravel development server:
php artisan serve - Open your web browser and navigate to
http://localhost:8000/dashboard. - You should see the AdminLTE dashboard displaying your sample content.
Conclusion
You have successfully integrated the AdminLTE HTML theme into your Laravel 10 e-commerce application. You can now customize your dashboard and add more features as needed. For further enhancements, consider exploring AdminLTE's extensive components and plugins to enrich your admin panel. Happy coding!