My system is Manjaro based on Archlinux, some of the commands might be different for your system.
- Install php-sqlite:
sudo pacman -S php-sqlite
- Activate the SQLite driver for php by editing
/etc/php/php.ini
:
uncomment the line ;extension=sqlite3
by removing the ;
.
- Restart apache, in my case:
sudo systemctl restart httpd.service
.
- You can check if SQLite is active in php by writing
<?php phpinfo();
into a php file and open it in your browser.
- Download the adminer-editor source file from the Adminer Editor page and rename it to
adminer-editor.php
.
- Download
plugin.php
and login-password-less.php
from the Plugins page and put them into the plugins
subfolder.
- If you don't have a SQLite database file you can create it with
sqlite3 database.db
in terminal.
- Download the
sqlite.php
file from the adminer github repository and save it as index.php
.
- Your folder structure should be like this:
adminer-editor.php
database.db
index.php
plugins/
|__ login-password-less.php
|__ plugin.php
- 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';
- 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:
- The folder containing the SQLite database file must give appropriate write permissions so that a lock file can be created next to the database file at any time you are using it. A good solution might be to put the database file in its own subfolder. Make sure that the file itself can not be accessed from the web, maybe using .htaccess and/or .htpasswd files.
- Some text editors will break the translation functionality in the adminer php files after editing them. If this happens to you, re-download the original file and use a different editor. In my case,
micro
did break them, nano
didn't.
Some questions that are left on my side:
- Is there a way to set different Usernames for different users?
- What does the
// TODO
line mean; Is there a way that I don't have to store the password in plain text in my index.php
file?
- Any other improvements you would like to suggest?