Installing Backpack for Laravel Modules with a Line of Command | by Shinichi Okada

[ad_1]

Laravel Admin Modules for Your Next Laravel App

backpack_install in action. GIF image.
backpack_install in action. GIF image by Author.

[Update 2021–05–29]

Laravel is the most popular PHP framework and Backpack for Laravel is a simple MVC architecture to create flexible admin panels.

Backpack for Laravel has a core module and 8 other modules, including PageManager, Settings, MenuCrud, NewsCrud, BackupManager, PermissionManager, LogManager, and FileManager.

I came to know Backpack for Laravel 4 years ago after Laravel released version 5. Back then, I created my first CMS/shopping cart using CodeIgniter and moving to Laravel. I was looking for the backend modules and I found the perfect match for my CMS. I used module PageManager for general pages, NewsCrud for blog articles, PermissionManager for user access control, FileManager for file management, etc. It had everything I needed to create my own CMS/Web app backend.

One of the best things is that it is free for a personal project. You can find more details about licensing and conditions here.

I haven’t used PHP for nearly three years and I just started creating my personal web app using Backpack for Laravel.

The installation for each module is simple and well-documented. Then I thought, why not automate the installation process for all the modules. I came up with my solution using a Bash script. I call it backpack_install. This script automates the installation of all 8 Backpack for Laravel modules from your terminal.

I tested it on macOS and it should work on Linux. I’d like to ask someone to test it on Windows 10 using Windows Subsystem for Linux 2 (WSL2).

Awesome package manager

After installing the Awesome package manager:

awesome install shinokada/backpack_install

macOS

brew tap shinokada/backpack_install
brew install backpack_install

Linux

Create ~/bin directory and add the path to your terminal config.

mkdir ~/bin
echo export PATH="$HOME/bin:$PATH" > ~/.bashrc

You can clone or download the repo and move it to the ~/bin directory.

git clone [email protected]:shinokada/backpack_install.git
mv backpack_install ~/bin
  • You must have Laravel installed and connected to a database.
  • No data in the database.

Setting up

composer create-project laravel/laravel myproject

If you are using MAMP you need to use 127.0.0.1 for the host and 8889 for the port.

...
APP_URL=http://127.0.0.1:8000
# .env DB example for MAMP
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=8889
DB_DATABASE=your-db-name
DB_USERNAME=root
DB_PASSWORD=root
...
php artisan serve

Install all modules at once

From your new project directory, run backpack_install.

backpack_install

The script confirms if your database connection.

Running backpack_install.
Running backpack_install. Image by Author.

Install modules one by one

You can install modules one by one. In this way, you can control which modules you want to install. It will ask you for each module.

For example:

backpack_install -p

Installing to another directory

You can run from any directory. You just need to give -d /path/to/myproject:

backpack_install -d ~/Laravel/myproject

Get help

backpack_install -h
The outputs from running ./backpack_install -h.
The outputs from running ./backpack_install -h. Image by Author.

Get version

backpack_install -v

You can uninstall all modules using the -u flag.

backpack_install -u

For example, uninstalling a Laravel project in ~/Laravel/myproject:

backpack_install -u -d ~/Laravel/myproject
Running backpack_install -u -d ~/Laravel/myproject.
backpack_install -u -d ~/Laravel/myproject on a terminal. Image by Author.
Uninstallation in action. GIF image.
Uninstallation in action. GIF image by Author.

After running uninstallation using the -u flag, you are recommended to run git reset and git clean.

$ cd $laravel_dir
$ git reset --hard
$ git clean -f -d

Clean your database.

To use the BackupManager, you need to configure BackupManager optional.

Check the installation by going to http://127.0.0.1:8000/admin. (You may need to change the URL.) Click the Register link and create a new user.

Backpack for Laravel quick tour

You will see a side menu to navigate yourself.

Backpack for Laravel in action. Gif image.
Backpack for Laravel in action. Gif image by Author.

It takes about 80–90 seconds to install all eight modules. I highly recommend Backpack for Laravel for your next PHP project. Getting Started Videos will be your next step to watch. I’m sure the Backpack for the Laravel team will continue to develop new and better solutions. Give it a go with backpack_install and please let me know how it goes.

Happy coding.

If you like my article and would like to receive newsletters, please sign up.

Get full access to every story on Medium by becoming a member.

[ad_2]

Leave a Comment