PHP code example of ssbityukov / filament-command-center

1. Go to this page and download the library: Download ssbityukov/filament-command-center 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/ */

    

ssbityukov / filament-command-center example snippets


use Bityukov\CommandCenter\Filament\CommandCenterPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        // ...
        ->plugin(CommandCenterPlugin::make());
}

// app/Providers/AppServiceProvider.php, in boot()
use Illuminate\Support\Facades\Gate;

Gate::define('command-center:access', fn ($user) => $user->is_admin);
Gate::define('command-center:manage-commands', fn ($user) => $user->is_admin);
Gate::define('command-center:prune-history', fn ($user) => $user->is_admin);

// config/command-center.php
'commands' => [
    'clear-cache' => [
        'run' => 'cache:clear',
        'label' => 'Clear application cache',
        'group' => 'Maintenance',
        'timeout' => 30,
    ],
    'migrate' => [
        'run' => 'migrate',
        'ability' => 'run-migrations',   // now only this gate may run it
        'confirm' => 'Apply pending migrations?',
    ],
],

'route-list' => [
    'run' => 'route:list --path={path}',
    'variables' => [
        'path' => ['type' => 'text', 'label' => 'Path filter', 'rules' => ['string', 'max:255']],
    ],
    'flags' => ['--json' => ['label' => 'As JSON']],
],

'backup-db' => [
    'run' => 'backup:run',
    'ability' => 'run-backups',
],

'backup-db' => ['run' => 'backup:run', 'queue' => true, 'timeout' => 600],

$this->line('##CC_PROGRESS:'.$percent.'##');

'history' => ['driver' => 'database'],

'sources' => [
    \Bityukov\CommandCenter\Sources\ConfigSource::class,
    \Bityukov\CommandCenter\Sources\DatabaseSource::class,
],
bash
php artisan vendor:publish --tag=command-center-config
bash
php artisan vendor:publish --tag=command-center-migrations
php artisan migrate
php artisan command-center:prune --days=30
bash
php artisan vendor:publish --tag=command-center-migrations
php artisan migrate
bash
php artisan command-center:check