PHP code example of protonemedia / laravel-task-runner
1. Go to this page and download the library: Download protonemedia/laravel-task-runner 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/ */
protonemedia / laravel-task-runner example snippets
ComposerGlobalUpdate::dispatch();
class ComposerGlobalUpdate extends Task
{
public function render(): string
{
return 'composer global update';
}
}
$output = ComposerGlobalUpdate::dispatch();
$output->getBuffer();
$output->getExitCode();
$output->getLines(); // returns the buffer as an array
$output->isSuccessful(); // returns true when the exit code is 0
$output->isTimeout(); // returns true on a timeout
$output->getIlluminateResult();
class GetFile extends Task
{
public function __construct(public string $path)
{
}
public function options()
{
return '-n';
}
}
GetFile::make('/etc/hosts')->dispatch();
class ComposerGlobalUpdate extends Task
{
protected int $timeout = 60;
}
use ProtoneMedia\LaravelTaskRunner\Facades\TaskRunner;
/** @test */
public function it_updates_composer_globally()
{
TaskRunner::fake();
$this->post('/api/composer/global-update');
TaskRunner::assertDispatched(ComposerGlobalUpdate::class);
}