Build Custom Admin Panels With Backpack for Laravel

Last updated on by

Build Custom Admin Panels With Backpack for Laravel image

Backpack for Laravel is a collection of packages which allows you to create admin panels for any web app quickly. It provides a set of useful packages divided into three categories that will make the process of creating a highly customizable admin panel easier.

Installation

The fastest way to take a look at Backpack is by using the ready-made demo app which comes with all the packages preinstalled. If you want to use it in a real app, read the manual installation documentation which will be more suitable; you will only choose the packages you need.

To use the demo app, clone the demo repo by running the following command:

git clone https://github.com/Laravel-Backpack/demo.git backpack-demo

Then, customize your database information in the .env file.

Next, install the package through Composer by running:

composer install

Now, migrate the database by running the following command:

php artisan migrate

If you are using Valet, you can access the demo admin panel by visiting http://backpack-demo.dev/admin in your browser.

Create a new user by clicking the register button on the top nav and filling in the form with your credentials. After you’ve logged in, you will see the Dashboard page:

Overview

Backpack comes with three different types of packages: core packages, ready-made CRUDs, and extensions.

Core Packages

There are two core packages. The first is Backpack\Base which consists of the AdminLTE theme integrated with an alert component and some views for login, register, forgotten passwords, and errors pages.

The second package is Backpack\CRUD which is accelerating the process of building CRUDs for admin panels. It provides more than 44 field types, DataTables integration, file browsing, and creating form requests for backend validation.

You can use Backpack\CRUD for building CRUDs manually like in this example in the docs, but we will take a look at a faster way for automatic CRUDs generation using Backpack\Generators later in this article.

Ready-Made CRUDs

Backpack provides five already built CRUDs which target the most commonly used CRUDs in web apps. Let’s take a look:

Backpack PermissionManager:

A CRUD for managing users, roles, and permissions so you can assign a user multiple roles and permissions.

Backpack Settings

An interface for easily changing the application settings, it provides different types of settings such as email, check boxes, text, numbers, etc. Be aware it does not include an interface for adding new settings, so you should add them directly to the database. If you want to retrieve any a setting’s value you can use Config::get('settings.admin_name').

Backpack PageManager

It’s a CRUD for creating pages for your website using predefined templates with any fields you want and ability to use various fields types. To define your templates, open app/PageTemplates.php file and add your template like this:

Now, you can create a new page using our new template like this:

Backpack NewsCRUD

It’s a CRUD for quickly creating anything related to news; you create articles, tags, categories with support for nesting categories and reordering them.

Add article interface:

Categories management page:

Backpack MenuCRUD

A CRUD for adding, editing, deleting, reordering, and nesting menu items. It provides the ability to use internal or external links, and you can link to a page from Backpack\PageManager.

Extensions Packages

Currently, there are three extension packages for Backpack; let’s take a look at each of them:

Backpack BackupManager:

An interface for creating and managing backups for files and database, it provides support for various drivers like S3, Dropbox, Google Drive, Box, etc. For more details, check out the package readme at github.

Backpack LogManager

An interface for dealing with Laravel log files. You can download, preview, or delete without accessing your server through SSH.

Backpack Generators

The generator is an essential package as it will accelerate the process of creating CRUDs and make it as simple as running a single command!

Let’s assume that we want to create a CRUD for products, so we want the following:

  • A database table called products.
  • A model app/Models/Product.php
  • A controller app/Http/Controllers/Admin/ProductCrudController.php
  • A request app/Http/Requests/ProductCrudRequest.php
  • A new route

To make that with Backpack\Generators:

  • First, make the migration file:
php artisan make:migration:schema create_products_table --schema="name:string:unique" --model=0
  • Then, migrate to the database:
php artisan migrate
  • After that, use Backpack\Generators to create the CRUD:
php artisan backpack:crud product
  • Last, open your routes/web.php to add the following route:
Route::group(['prefix' => config('backpack.base.route_prefix', 'admin'), 'middleware' => ['web', 'auth']], function () {
CRUD::resource('product', 'Admin\ProductCrudController');
});

Now, if you use Valet, open http://backpack-demo.dev/admin/product in your browser and access the Products CRUD page so you can add and manage products easily:

Backpack Pricing

Backpack has several tiers of pricing and you can save 20% off using the cuopon LARAVELNEWS.


That’s it; if you want a way for creating admin panels for any web app quickly, try Backpack for Laravel. For more details about usage, options, and customization check out the documentation.

Diaa Fares photo

Laravel Artisan, Web Developer, Tech Geek

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.

image
Paragraph

Manage your Laravel app as if it was a CMS – edit any text on any page or in any email without touching Blade or language files.

Visit Paragraph
Laravel Forge logo

Laravel Forge

Easily create and manage your servers and deploy your Laravel applications in seconds.

Laravel Forge
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell
No Compromises logo

No Compromises

Joel and Aaron, the two seasoned devs from the No Compromises podcast, are now available to hire for your Laravel project. ⬧ Flat rate of $7500/mo. ⬧ No lengthy sales process. ⬧ No contracts. ⬧ 100% money back guarantee.

No Compromises
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
Bacancy logo

Bacancy

Supercharge your project with a seasoned Laravel developer with 4-6 years of experience for just $2500/month. Get 160 hours of dedicated expertise & a risk-free 15-day trial. Schedule a call now!

Bacancy
Lucky Media logo

Lucky Media

Bespoke software solutions built for your business. We ♥ Laravel

Lucky Media
Lunar: Laravel E-Commerce logo

Lunar: Laravel E-Commerce

E-Commerce for Laravel. An open-source package that brings the power of modern headless e-commerce functionality to Laravel.

Lunar: Laravel E-Commerce
LaraJobs logo

LaraJobs

The official Laravel job board

LaraJobs
All Green logo

All Green

All Green is a SaaS test runner that can execute your whole Laravel test suite in mere seconds so that you don't get blocked – you get feedback almost instantly and you can deploy to production very quickly.

All Green
Larafast: Laravel SaaS Starter Kit logo

Larafast: Laravel SaaS Starter Kit

Larafast is a Laravel SaaS Starter Kit with ready-to-go features for Payments, Auth, Admin, Blog, SEO, and beautiful themes. Available with VILT and TALL stacks.

Larafast: Laravel SaaS Starter Kit
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit
Rector logo

Rector

Your partner for seamless Laravel upgrades, cutting costs, and accelerating innovation for successful companies

Rector

The latest

View all →
Asserting Exceptions in Laravel Tests image

Asserting Exceptions in Laravel Tests

Read article
Reversible Form Prompts and a New Exceptions Facade in Laravel 11.4 image

Reversible Form Prompts and a New Exceptions Facade in Laravel 11.4

Read article
Basset is an alternative way to load CSS & JS assets image

Basset is an alternative way to load CSS & JS assets

Read article
Integrate Laravel with Stripe Connect Using This Package image

Integrate Laravel with Stripe Connect Using This Package

Read article
The Random package generates cryptographically secure random values image

The Random package generates cryptographically secure random values

Read article
Automatic Blade Formatting on Save in PhpStorm image

Automatic Blade Formatting on Save in PhpStorm

Read article