PHP code example of binarybuilds / filament-command-runner

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

    

binarybuilds / filament-command-runner example snippets


php artisan vendor:publish --tag=command-runner-migrations

use BinaryBuilds\CommandRunner\CommandRunnerPlugin;

$panel->plugin(CommandRunnerPlugin::make());


CommandRunnerPlugin::make()->authorize(fn () => auth()->user()->can('view-command-runner'))

CommandRunnerPlugin::make()->navigationGroup('System')

CommandRunnerPlugin::make()->navigationLabel('Command Runner')

CommandRunnerPlugin::make()->navigationIcon('heroicon-o-exclamation-triangle')

CommandRunnerPlugin::make()->navigationSort(10)

use Illuminate\Support\Str;

$panel->plugin(
    CommandRunnerPlugin::make()->validateCommand(function (string $attribute, string $value, \Closure $fail) {
        if (!Str::startsWith($value, 'php artisan')) {
            $fail("You can only run artisan commands");
        }
    })
);

$panel->plugin(
    CommandRunnerPlugin::make()->canDeleteCommandHistory(fn ($user) => $user->isAdmin())
);

php artisan migrate
bash
php artisan command-runner:purge-history
bash
php artisan command-runner:purge-history 7