PHP code example of lukaskleinschmidt / kirby-terminal

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

    

lukaskleinschmidt / kirby-terminal example snippets




return [
    'lukaskleinschmidt.terminal.scripts' => [
        'hello-world' => 'echo "Hello World!"',
        'list-index' => function () {
            return 'ls';
        },
        'list-content' => function () {
            $cwd = $this->kirby()->root('content') . '/' . $this->diruri();

            // Set the current working directory for the script
            return script('ls', $cwd);
        },
    ]
];



return [
    'lukaskleinschmidt.terminal.scripts' => [
        'deploy' => function () {
            $source = $this->kirby()->root('content') . '/\./' . $this->diruri();
            $target = '[email protected]:/var/www/html/content';

            // If you are not 100% certain you have the right path on the remote
            // server then test this command without the --delete flag first
            return "rsync --delete --relative -avz $source $target";
        }
    ]
];



return [
    'lukaskleinschmidt.terminal.gate' => function ($user) {
        return in_array($user->email(), [
            '[email protected]'
        ]);
    }
];



return [
    'lukaskleinschmidt.terminal.gate' => function ($user) {
        $permissions = [
            '[email protected]' => ['deploy']
        ];

        return in_array($this->script(), $permissions[$user->email()] ?? []);
    }
];


// config.example.com.php

return [
    'lukaskleinschmidt.terminal.gate' => false,
];



return [
    'lukaskleinschmidt.terminal.endpoint' => 'custom-terminal-endpoint'
];
yml
confirm:
  en: Are you sure you are ready for this?
  de: Bist du sicher, dass du bereit bist?