phpsqlite

How to use Adminer Editor with SQLite?


I want to use the 'light' version of Adminer called Adminer Editor to access a SQLite3 database file in the same directory.

The documentation on the official website doesn't seem to be too extensive and I am still trying it took me a long time to find a working solution.

I was able to overcome the None of the supported PHP extensions (SQLite3, PDO_SQLite) are available. error.

Later I was stuck at the Database does not support password. error.

After this I was confronted with the attempt to write a readonly database error.

I hope my experience will help other people using adminer editor.


Solution

  • My system is Manjaro based on Archlinux, some of the commands might be different for your system.

    1. Install php-sqlite: sudo pacman -S php-sqlite
    2. Activate the SQLite driver for php by editing /etc/php/php.ini:
      uncomment the line ;extension=sqlite3 by removing the ;.
    3. Restart apache, in my case: sudo systemctl restart httpd.service.
    4. You can check if SQLite is active in php by writing <?php phpinfo(); into a php file and open it in your browser.
    5. Download the adminer-editor source file from the Adminer Editor page and rename it to adminer-editor.php.
    6. Download plugin.php and login-password-less.php from the Plugins page and put them into the plugins subfolder.
    7. If you don't have a SQLite database file you can create it with sqlite3 database.db in terminal.
    8. Download the sqlite.php file from the adminer github repository and save it as index.php.
    9. Your folder structure should be like this:
        adminer-editor.php
        database.db
        index.php
        plugins/
               |__ login-password-less.php
               |__ plugin.php
    
    
    1. Edit your index.php file. The content of my file is this:
    <?php
    function adminer_object() {
      
      include_once "plugins/plugin.php";
      include_once "plugins/login-password-less.php";
      
        class AdminerCustomization extends AdminerPlugin {
            function loginFormField($name, $heading, $value) {
                return parent::loginFormField($name, $heading, str_replace('value="server"', 'value="sqlite"', $value));
            }
            function database() {
                return "database.db";
            }
        }
        
        return new AdminerCustomization(array(
            // TODO: inline the result of password_hash() so that the password is not visible in source codes
            new AdminerLoginPasswordLess(password_hash("password", PASSWORD_DEFAULT)),
        ));
    }
    include 'adminer-editor.php';
    
    1. You can now browse to your index.php, leave the Username field empty and enter the password equal to the one in your index.php.

    edit: Some things to note:


    Some questions that are left on my side: