titasgailius/terminal
A lightweight PHP package for building and running terminal commands. Compose commands with a fluent API, execute processes, stream output, handle timeouts and exit codes, and run tasks cross-platform—ideal for artisan tools, deploy scripts, and CI automation.
Full Changelog: https://github.com/TitasGailius/terminal/compare/1.2.0...1.2.1
To use Terminal with PHP 8.x, please upgrade Terminal to the ^1.0 version.
composer.json to use the latest version of the terminal: "titasgailius/terminal": "^1.0".Builder::retry is now a protected method. It's very unlikely that you were was using this method..Alternatively you can also check that a given command was not executed. You may accomplish this by calling the Terminal::assertNotExecuted method after calling Terminal::fake.
Terminal::fake();
Terminal::assertNotExecuted('php artisan migrate');
You may enable or disable TTY mode:
Terminal::enableTty()->run(...);
Terminal::disableTty()->run(...);
You may specify max allowed time since last output:
// Seconds.
Terminal::idleTimeout(20)->run(...);
// Carbon.
Terminal::idleTimeout(Carbon::now()->addSeconds(20))->run(...);
// DateInterval.
Terminal::idleTimeout(new DateInterval('PT20S'))->run(...);
If you run Terminal from the Laravel's Artisan command, you may send the output to the console by
passing an instance of the Command to the output method:
public function handle()
{
Terminal::output($this)->run('echo Hello, World');
}
If you run Terminal from the Symfony's Console command, you may send the output to the console by
passing an instance of the OutputInterface to the output method:
protected function execute(InputInterface $input, OutputInterface $output)
{
Terminal::output($output)->run('echo Hello, World');
}
Fixes a bug with "retries" option.
There was a typo when proxying missing methods of the Builder instance to the Process instance.
This release makes it possible to set input for the Symfony Process:
Terminal::input($input)->run('rm -rf vendor');
If you need to pass any data to your command line, it's better to bind it using the with method.
Terminal can escape and prepare the values for you. Reference these values using the {{ $key }} syntax.
Terminal::with([
'firstname' => 'John',
'lastname' => 'Doe',
])->run('echo Hello, {{ $firstname}} {{ $lastname }}');
Alternatively, you may pass the key-value pair in separate parameters.
Terminal::with('greeting', 'World')
->run('echo Hello, {{ $greeting }}');
Initial release
How can I help you explore Laravel packages today?