PHP code example of lucapellegrino / dbmyadmin

1. Go to this page and download the library: Download lucapellegrino/dbmyadmin 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/ */

    

lucapellegrino / dbmyadmin example snippets


use LucaPellegrino\DbMyAdmin\DbMyAdminPlugin;

->plugins([
    DbMyAdminPlugin::make(),
])

return [
    // Database driver: auto-detected from your DB connection, or set manually
    // Accepted values: 'auto', 'mysql', 'pgsql', 'sqlite'
    'driver' => 'auto',

    // Tables hidden from the table list
    'excluded_tables' => [
        'migrations',
        'dbmyadmin_saved_queries',
        'sessions',
        'cache',
        'jobs',
        'failed_jobs',
        'password_reset_tokens',
        'personal_access_tokens',
    ],

    // SQL Runner settings
    'query_runner' => [
        // SQL statement types blocked in the SQL Runner for safety
        // Add or remove entries to customize which statements are blocked
        'blocked_statements' => [
            'DROP', 'TRUNCATE', 'ALTER', 'CREATE',
            'RENAME', 'GRANT', 'REVOKE', 'LOCK', 'UNLOCK',
        ],

        // Maximum rows returned per query execution
        'max_rows' => 1000,
    ],

    // Name of the table used to store saved queries
    'saved_queries_table' => 'dbmyadmin_saved_queries',

    // Whether to log all operations (CREATE, ALTER, query execution, etc.)
    'logging' => true,
];

'excluded_tables' => [
    'migrations',
    'dbmyadmin_saved_queries',
    'my_sensitive_table',
    'internal_logs',
],

// Allow TRUNCATE (not recommended in production)
'blocked_statements' => [
    'DROP', 'ALTER', 'CREATE', 'RENAME',
    'GRANT', 'REVOKE', 'LOCK', 'UNLOCK',
],

// Block everything except SELECT
'blocked_statements' => [
    'DROP', 'TRUNCATE', 'ALTER', 'CREATE', 'RENAME',
    'GRANT', 'REVOKE', 'LOCK', 'UNLOCK',
    'INSERT', 'UPDATE', 'DELETE',
],

DbMyAdminPlugin::make()
    ->authorize(fn() => auth()->user()->hasRole('superadmin'))

DbMyAdminPlugin::make()
    ->navigationGroup('Administration')
    ->navigationIcon('heroicon-o-circle-stack')
bash
php artisan vendor:publish --tag=dbmyadmin-migrations
php artisan migrate
bash
php artisan vendor:publish --tag=dbmyadmin-config