PHP code example of filaforge / filament-terminal-console

1. Go to this page and download the library: Download filaforge/filament-terminal-console 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/ */

    

filaforge / filament-terminal-console example snippets


use Filament\Panel;

public function panel(Panel $panel): Panel
{
    return $panel
        // ... other configuration
        ->plugin(\Filaforge\TerminalConsole\TerminalConsolePlugin::make());
}

// config/terminal-console.php
return [
    'enabled' => env('TERMINAL_CONSOLE_ENABLED', true),
    'allowed_commands' => [
        'ls', 'cd', 'pwd', 'cat', 'grep', 'find',
        'ps', 'top', 'htop', 'df', 'du', 'mkdir',
        'rm', 'cp', 'mv', 'chmod', 'chown', 'tar',
        'gzip', 'unzip', 'wget', 'curl', 'git'
    ],
    'blocked_commands' => [
        'rm -rf /', 'dd', 'mkfs', 'fdisk', 'shutdown',
        'reboot', 'halt', 'poweroff', 'init 0', 'rm -rf /*'
    ],
    'restricted_directories' => [
        '/etc', '/var/log', '/home', '/root', '/boot'
    ],
    'max_execution_time' => env('TERMINAL_CONSOLE_TIMEOUT', 300),
    'max_output_lines' => env('TERMINAL_CONSOLE_MAX_OUTPUT', 1000),
    'session_timeout' => env('TERMINAL_CONSOLE_SESSION_TIMEOUT', 3600),
    'log_commands' => env('TERMINAL_CONSOLE_LOG_COMMANDS', true),
    'allowed_users' => ['admin', 'developer', 'system_manager'],
];

// remove ->plugin(\Filaforge\TerminalConsole\TerminalConsolePlugin::make())
bash
# Publish provider groups (config, views, migrations)
php artisan vendor:publish --provider="Filaforge\\TerminalConsole\\Providers\\TerminalConsoleServiceProvider"

# Run migrations
php artisan migrate
bash
# Test if basic commands work
php artisan tinker
shell_exec('pwd');
shell_exec('ls -la');
bash
php artisan optimize:clear