1. Go to this page and download the library: Download shel/neos-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/ */
shel / neos-terminal example snippets
declare(strict_types=1);
namespace Vendor\Package\Command;
use Neos\Flow\Http\Client\Browser;
use Neos\Flow\Http\Client\CurlEngine;
use Shel\Neos\Terminal\Domain\CommandContext;
use Shel\Neos\Terminal\Domain\CommandInvocationResult;
use Shel\Neos\Terminal\Command\TerminalCommandInterface;
class JokeCommand implements TerminalCommandInterface
{
public static function getCommandName(): string
{
return 'jod';
}
public static function getCommandDescription(): string
{
return 'Joke of the day';
}
public static function getCommandUsage(): string
{
return 'jod [<string>]';
}
public function invokeCommand(string $argument, CommandContext $commandContext): CommandInvocationResult
{
$browser = new Browser();
$browser->setRequestEngine(new CurlEngine());
$jokeResponse = json_decode($browser->request('https://api.jokes.one/jod')->getBody()->getContents());
$joke = $jokeResponse->contents->jokes[0]->joke;
$result = $joke->title . ': ' . $joke->text;
return new CommandInvocationResult(true, $result);
}
}
public function invokeCommand(string $argument, CommandContext $commandContext): CommandInvocationResult
{
$newNodeTitle = $argument;
$commandContext->getFocusedNode()->setProperty('title', $newNodeTitle);
$result = 'I updated the node title';
$feedback = [
new \Neos\Neos\Ui\Domain\Model\Feedback\Operations\ReloadDocument()
];
return new CommandInvocationResult(true, $result, $feedback);
}
if (interface_exists('Shel\Neos\Terminal\Command\TerminalCommandInterface', false)) {
class JokeCommand implements \Shel\Neos\Terminal\Command\TerminalCommandInterface
{
public static function getCommandName(): string { ... }
public static function getCommandDescription(): string { ... }
public static function getCommandUsage(): string { ... }
public function invokeCommand(string $argument, \Shel\Neos\Terminal\Domain\CommandContext $commandContext): \Shel\Neos\Terminal\Domain\CommandInvocationResult {
...
return new \Shel\Neos\Terminal\Domain\CommandInvocationResult(true, $result);
}
}
} else {
class JodCommand {}
}
flushCache Neos_Fusion_Content
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.