Adminer/Adminer Editor for Lumen/Laravel 5.*
127
1
2
Package Data
Maintainer Username: HeshamMeneisi
Maintainer Contact: heshammeneisi@gmail.com (Hesham)
Package Create Date: 2019-04-25
Package Last Update: 2019-05-03
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2024-11-19 03:05:56
Package Statistics
Total Downloads: 127
Monthly Downloads: 3
Daily Downloads: 0
Total Stars: 1
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

Lumener

Scrutinizer Code Quality Build Status Latest Packagist Version Software License

Adminer is a full-featured database management tool written in PHP. This package integrates the adminer interface into your Lumen or Laravel project by acting as a wrapper and taking care of incompatibility issues. Lumener also provides means to update, stylize or extend adminer through the artisan commands.

This was initially forked from leung/laravel-adminer. The package was developed and tested using Lumen. So, Laravel support is untested (Although no changes should break it). Feel free to test on Laravel and open issues and/or submit a pull request!

Requirements

General

  • guzzlehttp/guzzle

Lumen

  • illuminate/cookie
  • illuminate/session

Installation

# Install package
composer require hgists/lumener
# Download latest Adminer
php artisan lumener:update
# [Optional] Apply theme
php artisan lumener:stylize

For Lumen or Laravel 5.4 or older, see the next section.


Provider

The provider will automatically create any required roots and enable the artisan commands.

Lumen

open your bootstrap/app.php and add this line anywhere before return $app;

$app->register(\Lumener\LumenerServiceProvider::class);

Laravel ≤ 5.4

Open your config/app.php and add this line in providers section

Lumener\LumenerServiceProvider::class

Laravel 5.5+

Auto package discovery should add the provider.


Config

You don't need to create a config file as all configuration parameters have a fallback value. You can follow the following instructions to customize the configuration.

  • Create a config/lumener.php file or use php artisan vendor:publish (Laravel only)
  • For Lumen, you must also add the following line to bootstrap/app.php before return $app;
$app->configure('lumener');

Artisan Commands

Updating Adminer

php artisan lumener:update [OPTIONAL --force]

You can configure your composer.json to do this after each commit:

"scripts": {
    "post-install-cmd": [
        "php artisan lumener:update"
    ],
    "post-update-cmd": [
        "php artisan lumener:update"
    ]
}

You can also create a route to update lumener with the action \Lumener\Controllers\LumenerController@update.

Themes

php artisan lumener:stylize [OPTIONAL --file] [OPTIONAL --url]

Default

If no arguments provided, this command will install the default theme already packed in with Lumener: Material Design for Adminer

php artisan lumener:stylize

alt text

For more themes, check the Adminer website.

File

php artisan lumener:stylize --file=/home/Downloads/adminer.css

URL

php artisan lumener:stylize --url=https://raw.githubusercontent.com/vrana/adminer/master/designs/lucas-sandery/adminer.css

For themes containing images/JavaScript you will have to copy the files manually to your public path.

Plugins

Install or update any plugin given its path or url.

php artisan lumener:plugin [OPTIONAL --file] [OPTIONAL --url]

Plugins must be enabled in config('lumener.adminer.plugins.enabled'). Refer to the config section.

Default

If no arguments provided, this command will install the plugin.php file which is required for any plugins to run.

php artisan lumener:plugin

File

php artisan lumener:plugin --file=/home/Downloads/designer.php

URL

php artisan lumener:plugin --url=https://raw.github.com/vrana/adminer/master/plugins/database-hide.php

Extensions

Adminer supports Extensions. In fact, Lumener takes advantage of quite a few extension functions. However, more extensions can be added using another user-defined class. This can be done all while preserving the original Lumener extensions, unless a conflict arises. Please take some time to check src/logic/adminer_object before writing your own extensions to be aware of potential conflicts.

To add your own extensions, set config('lumener.adminer.extension_file').

"adminer" => [
    ...
    "extension_file" => base_path("app/Logic/LumenerExtension.php")
    ...
]

Example file:

<?php
// Lumener and $plugins are already defined before this file is included
class ExtendedLumener extends Lumener
{
    function permanentLogin() {
      // key used for permanent login
      return 'ca41d8e9879df648e9a43cefa97bc12d';
    }
}

if (empty($plugins)) {
    return new ExtendedLumener();
}
return new ExtendedLumener($plugins);

Custom Route

You can modify route attributes in config('lumener.route').

Lumen Special

You may add a route to your own routes file (e.g. routes/web.php) with the name lumener and it will override all attributes, except for namespace.

$router->addRoute(null, 'lumener', ['middleware' => ['auth'], 'as' => 'lumener']);

This also works if you add the route inside an existing group.

$router->group(
    ['middleware' => ['encrypt_cookies', 'auth', 'level:100'], 'prefix' => 'admin'],
    function () use ($router) {
        $router->addRoute(null, 'lumener', ['as' => 'lumener']);
    }
);

Using specific HTTP methods is not supported, please keep it null. The route path and options here will override config('lumener.route').

Laravel Special

You can define a middleware group named lumener and it will be automatically used in the LumenerController.

Additionally, add the lumener route to $except to avoid CSRF issues

protected $except = [
     'lumener'
 ];

Embedding

The route can be redirected to a function in a user-defined controller. This is done by overriding the uses option either in config('lumener.route.options.uses') or in the user-defined route (Lumen).

The following code is a simple example of how embedding might work.

class AdminController{
   public function __construct(Request $request)
   {
       $this->request = $request;
   }
   public function lumener()
   {
       // If you are using a Content Seucrity Policy, define it here
       define("LUMENER_CSP", [["form-action" => "'self'"]]);
       $controller = new \Lumener\Controllers\LumenerController($this->request);
       $content = $controller->index();
       return view('admin.dashboard', ['content' => $content]);
   }
}
// Don't forget to use {!! $content !!} in blade as $content is HTML

Credits

License

The MIT License (MIT). Please see License File for more information.