1. Go to this page and download the library: Download lagdo/jaxon-dbadmin library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
lagdo / jaxon-dbadmin example snippets
'app' => [
// Other config options
// ...
'packages' => [
Lagdo\DbAdmin\App\DbAdminPackage::class => [
'servers' => [
// The database servers
'pgsql_server' => [ // A unique identifier for this server
'driver' => 'pgsql',
'name' => '', // The name to be displayed in the dashboard UI.
'host' => '', // The database host name or address.
'port' => 0, // The database port. Optional.
'username' => '', // The database user credentials.
'password' => '', // The database user credentials.
],
'mysql_server' => [ // A unique identifier for this server
'driver' => 'mysql',
'name' => '', // The name to be displayed in the dashboard UI.
'host' => '', // The database host name or address.
'port' => 0, // The database port. Optional.
'username' => '', // The database user credentials.
'password' => '', // The database user credentials.
],
],
],
],
],
$dbConfigProvider = function(array $config) {
$config['servers']['server_mysql'] = [
'driver' => 'mysql',
'name' => '', // The name to be displayed in the dashboard UI.
'host' => '', // The database host name or address.
'port' => 0, // The database port. Optional.
'username' => '', // The database user credentials.
'password' => '', // The database user credentials.
];
$config['servers']['server_pgsql'] = [
'driver' => 'pgsql',
'name' => '', // The name to be displayed in the dashboard UI.
'host' => '', // The database host name or address.
'port' => 0, // The database port. Optional.
'username' => '', // The database user credentials.
'password' => '', // The database user credentials.
];
return $config;
};
'app' => [
// Other config options
// ...
'packages' => [
Lagdo\DbAdmin\App\DbAuditPackage::class => [
// ...
'audit' => [
'enabled' => true,
],
'database' => [
// Same as the "servers" items, but "name" is the database name.
'driver' => 'pgsql',
'host' => '',
'port' => 0,
'username' => '',
'password' => '',
'name' => 'auditdb', // The database name
'schema' => '', // Optionnally, the schema name
],
],
],
],
'app' => [
// ...
'packages' => [
Lagdo\DbAdmin\App\DbAdminPackage::class => [
// Read the database credentials with the custom config reader.
'reader' => [
'server' => CustomServerConfigProvider::class,
],
// ...
],
Lagdo\DbAdmin\App\DbAuditPackage::class => [
// Read the database credentials with the custom config reader.
'reader' => [
'server' => CustomServerConfigProvider::class,
],
// ...
],
],
],
use Lagdo\DbAdmin\Support\Provider\AuthInterface;
use Lagdo\DbAdmin\Support\Provider\Secret\InfisicalConfigProvider;
$secretKetBuilder = function(string $prefix, string $option, AuthInterface $auth) {
// Select a secret key based on the authenticated user, and the option prefix and name.
return $secretKey;
};
$reader = jaxon()->di()->g(InfisicalConfigProvider::class);
$reader->setSecretKeyBuilder($secretKeyBuilder);
use Lagdo\DbAdmin\Support\Provider\Config\ServerConfigProvider;
use Lagdo\DbAdmin\Support\Provider\Secret\InfisicalConfigProvider;
'app' => [
// ...
'packages' => [
Lagdo\DbAdmin\App\DbAdminPackage::class => [
// Read the database credentials with the custom config reader.
'reader' => [
'server' => ServerConfigProvider::class,
'access' => InfisicalConfigProvider::class,
],
// ...
],
Lagdo\DbAdmin\App\DbAuditPackage::class => [
// Read the database credentials with the custom config reader.
'reader' => [
'server' => ServerConfigProvider::class,
'access' => InfisicalConfigProvider::class,
],
// ...
],
],
],
use League\Flysystem\FilesystemException;
use League\Flysystem\UnableToReadFile;
use League\Flysystem\UnableToWriteFile;
use function Jaxon\storage;
'app' => [
'storage' => [
'stores' => [
'exports' => [
'adapter' => 'local',
'dir' => "/path/to/exports",
],
],
],
'packages' => [
Lagdo\DbAdmin\App\DbAdminPackage::class => [
'servers' => [
// The database servers
],
'export' => [
'writer' => function(string $content, string $filename): string {
try {
// Make a Filesystem object with the storage.exports options.
$storage = storage()->get('exports');
$storage->write($filename, "$content\n");
} catch (FilesystemException|UnableToWriteFile) {
return '';
}
// Return the link to the exported file.
return "/export.php?file=$filename";
},
'reader' => function(string $filename): string {
try {
// Make a Filesystem object with the storage.exports options.
$storage = storage()->get('exports');
return !$storage->fileExists($filename) ?
"No file $filename found." : $storage->read($filename);
} catch (FilesystemException|UnableToReadFile) {
return "No file $filename found.";
}
},
],
],
],
],