Giter Club home page Giter Club logo

miroc-laravel-adminer's Introduction

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.

miroc-laravel-adminer's People

Contributors

jesseleite avatar jonasof avatar miroc avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.