How to install Adminer with PHP Laravel?

By Hardik Savani May 14, 2024 Category : PHP Laravel

Today, i am going to share with you how to install adminer in laravel 5, laravel 6, laravel 7, laravel 8, laravel 9, laravel 10 and laravel 11 application. As we know adminer is similar like phpmyadmin. So if you want to install adminer in your server then follow bellow step and get full example for installation of adminer in laravel framework.

Preview:

Install Package

In this step we have to laravel-adminer package for adminer so one your cmd or terminal and fire bellow command:

composer require onecentlin/laravel-adminer

After successfully install package, open config/app.php file and add service provider and alias.

config/app.php

'providers' => [

....

Onecentlin\Adminer\ServiceProvider::class,

],

we have to also make public configuration file by following command. So run bellow command:

php artisan vendor:publish --provider="Onecentlin\Adminer\ServiceProvider"

Middleware Configuration

here we will make configuration as listed files. So just configure listed files:

app/Http/Middleware/VerifyCsrfToken.php

<?php


namespace App\Http\Middleware;


use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;


class VerifyCsrfToken extends Middleware

{

/**

* The URIs that should be excluded from CSRF verification.

*

* @var array

*/

protected $except = [

'adminer'

];

}

app/Http/Kernel.php

<?php


namespace App\Http;


use Illuminate\Foundation\Http\Kernel as HttpKernel;


class Kernel extends HttpKernel

{

/**

* The application's global HTTP middleware stack.

*

* These middleware are run during every request to your application.

*

* @var array

*/

protected $middleware = [

.....

];


/**

* The application's route middleware groups.

*

* @var array

*/

protected $middlewareGroups = [

......

'api' => [

'throttle:60,1',

'bindings',

],

'adminer' => [

\App\Http\Middleware\EncryptCookies::class,

\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,

\Illuminate\Session\Middleware\StartSession::class,

// you may create customized middleware to fit your needs

\Illuminate\Auth\Middleware\Authenticate::class,

],

];


/**

* The application's route middleware.

*

* These middleware may be assigned to groups or used individually.

*

* @var array

*/

protected $routeMiddleware = [

.....

'adminer' => \App\Http\Middleware\Authenticate::class,

];

}

Run Project

Ok, now we are ready to run this example so quick run by following command:

php artisan serve

Now open your browser and run bellow link:

http://localhost:8000/adminer

I hope it can help you...

Shares