Skip to content
Adminer wrapper for Laravel 5
PHP
Branch: master
Clone or download
miroc Merge pull request #23 from senaranya/update-adminer-to-4.7.0
Update Adminer from v4.5.0 to v4.7.0
Latest commit 9f03b53 Jan 9, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Update Adminer from v4.5.0 to v4.7.0 Dec 16, 2018
.gitignore Initial commit May 2, 2015
README.md README updated - path to Laravel routes file Apr 2, 2017
composer.json Composer requirements update May 17, 2015

README.md

Laravel-Adminer

Laravel 5 wrapper for Adminer. Adminer is an excellent database management tool in a single PHP file written by Jakub Vrana. It's a great replacement for PhpMyAdmin (also supports PostgreSQL, SQLite, MS SQL, Oracle, Firebird, SimpleDB, Elasticsearch and MongoDB).

Usage

To include the library, go to your project's folder and run:

composer require "miroc/laravel-adminer"

To add adminer to Laravel routes (e.g. /adminer), update routes/web.php file with:

Route::any('adminer', '\Miroc\LaravelAdminer\AdminerController@index');

To autologin Adminer with Laravel default connection, add the following controller instead:

Route::any('adminer', '\Miroc\LaravelAdminer\AdminerAutologinController@index');

Disabling CSRF Middleware

Adminer doesn't work with VerifyCsrfToken middleware, so it has to be disabled on its route.

Laravel 5.1+

In VerifyCsrfToken.php disable CSRF by adding adminer route to $except array:

protected $except = [
    'adminer'
];

Laravel 5.0

The easiest way is to create a custom VerifyCsrfToken middleware that excludes selected routes:

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

class CustomVerifyCsrfToken extends VerifyCsrfToken {

    protected $excludedRoutes = ['adminer'];

	public function handle($request, Closure $next)
	{
        if ($this->isExcludedRoute($request)){
            return $next($request);
        } else {
            return parent::handle($request, $next);
        }
	}

    private function isExcludedRoute($request)
    {
        if (count($request->segments()) > 0
            && in_array($request->segment(1), $this->excludedRoutes)){
            return true;
        } else {
            return false;
        }
    }
}

And then use that instead of VerifyCsrfToken in Kernel.php

protected $middleware = [
	'Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode',
	'Illuminate\Cookie\Middleware\EncryptCookies',
	'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse',
	'Illuminate\Session\Middleware\StartSession',
	'Illuminate\View\Middleware\ShareErrorsFromSession',
	'Path\To\CustomVerifyCsrfToken',
];

Remarks

Due to function name conflicts of Laravel5 and Adminer, adminer.php file functions 'cookie()', 'redirect()' and 'view()' are prefixed with 'adm_' prefix.

If you find any problem, please let me know.

You can’t perform that action at this time.