pematon / adminer-plugins

Usefull plugins for Adminer database tool.
MIT License
32 stars 9 forks source link

Configuring AdminerLoginServer plugin #5

Closed peterdalydickson closed 6 years ago

peterdalydickson commented 6 years ago

It might just be me, but I'd really appreciate and benefit from more examples of how to configure the AdminerLoginServer.

Your addition of sqlite was great, and made sense because you gave a specific example. But I have no idea how I might have, for example, an SQLite database and a MySQL database in the dropdown.

Any examples or more detailed documentation would be awesome!

Thanks for a great enhancement to adminer 😊

peterpp commented 6 years ago

Hello, I'm not sure if you saw examples in source code of AdminerLoginServers plugin.

/**
 * Sets lists of supported database servers.
 *
 * Database server can be prefixed with driver name and can contain port and database name.
 * For example:
 * - mysql://localhost:3306 (server host and port)
 * - pgsql://localhost#database_name (server and database name)
 * - sqlite://database.db (relative path to database file, no authentication)
 * - sqlite://user:password@/var/www/#database.db (authentication, absolute path as 'server' and file name as 'database')
 *
 * Possible driver names are: `sqlite`, `sqlite2`, `pgsql`, `firebird`, `oracle`, `simpledb`, `elastic`, `mysql`,
 * `mongo`, `mssql`. Default driver is `mysql`.
 *
 * @param array $servers array(database-server) or array(database-server => description) or array(category => array())
 * @param string $defaultDriver Will be used if driver is not specified within server.
 */

So for SQLite together with MySQL you can use for example:

new AdminerLoginServers([
    "mysql://localhost",
    "sqlite://user:password@/var/www/#database.db",
]),

or:

new AdminerLoginServers([
    "mysql://localhost" => "My cool MySQL database",
    "sqlite://user:password@/var/www/#database.db" => "The coolest SQLite database",
]),

or:

new AdminerLoginServers([
    "Development" => [
        "mysql://localhost" => "My cool MySQL database",
        "sqlite://user:password@/var/www/#database.db" => "The coolest SQLite database",
    ],
    "Production" => [
        "mysql://111.222.333.444",
        "sqlite://user:password@/var/www/#production.db",
    ],
]),
peterdalydickson commented 6 years ago

I didn't! That's exactly what I was looking for. Thank you sir.