Görev (Task)
Paket yükleme&kaldırma ve benzeri tüm uzun süren işlemleri arkaplanda çalıştırıp arayüzde çıktıları göstermeyi kolaylaştıran Task(Görev) componentini öğreneceğiz.
Task Soyut Sınıfından Türeyen Bir Sınıf Oluşturmak
<?php
namespace App\Tasks;
use Liman\Toolkit\Formatter;
use Liman\Toolkit\RemoteTask\Task;
class InstallPackage extends Task
{
protected $command = "DEBIAN_FRONTEND=noninteractive apt install @{:package} -qqy";
protected $sudoRequired = true;
protected $control = "apt\|dpkg";
public function __construct(array $attributes = []){
if(!isset($attributes["package"])){
throw new \Exception("Package name is required");
}
$this->attributes = $attributes;
$this->logFile = Formatter::run(
"/tmp/install-package-{:package}.txt",
["package" => $attributes["package"]]
);
$this->checkCommand = Formatter::run(
"apt list --installed | grep {:package}",
["package" => $attributes["package"]]
);
}
}Görevleri Çalıştırmak
Blade İçerisinde Task Componentinin Kullanımı
Last updated
Was this helpful?