PHP code example of zowesoft / web-terminal

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

    

zowesoft / web-terminal example snippets


$user = User::where('email', '[email protected]')->first();
$user->is_admin       = true;
$user->terminal_token = bin2hex(random_bytes(32));
$user->save();

// Copy this token — you'll need it to log in to the terminal
echo $user->terminal_token;

// config/web-terminal.php

return [
    'prefix'       => 'admin',          // URL prefix: /admin/terminal
    'middleware'   => ['web', 'auth'],  // Applied to all terminal routes
    'timeout'      => 120,              // Max seconds per command
    'admin_column' => 'is_admin',       // Column that marks admin users
    'token_column' => 'terminal_token', // Column that stores the token

    'blacklist' => [
        'rm -rf /',
        'rm -rf *',
        // add more blocked commands here
    ],

    'path' => '/usr/local/bin:/usr/bin:/bin', // Shell PATH for finding executables
];
bash
php artisan vendor:publish --tag=web-terminal-migrations
php artisan migrate
bash
php artisan tinker
bash
php artisan vendor:publish --tag=web-terminal-config
bash
php artisan vendor:publish --tag=web-terminal-views
bash
php -r "echo shell_exec('php -v');"
bash
which git
which composer