Komut İşlemci Kütüphanesi
×
Bunları biliyor muydunuz?
"Kontrolcü yöntemlerine parametre olarak enjekte edilen sınıfların örneklerine aynı zamanda görünmlerinden de erişebilirsiniz."
"Kontrolcü yöntemlerine parametre olarak enjekte edilen sınıfların örneklerine aynı zamanda görünmlerinden de erişebilirsiniz."
Terminal üzerinden komut çalıştırmak için kullanılır. Bu kütüphane ssh2_exec, exec, system ve ssh yöntemlerinin bir araya getirilmesiyle derlenmiştir. Seçilen sürücü türüne göre çalışırlar.
# Kurulum
ZN dağıtımları için kurulum gerekmez.
↓ composer require znframework/package-prompt
# Yapılandırma
Dosya: Config/Services.php
Processor | ||
string | $driver = 'exec' | Sürücü türü. Yani kabuk komut işlemlerinde hangi yöntemin kullanılacağıdır. |
Seçenekler | exec, system, shell | |
string | $path = '/usr/bin/php' | Geçerli PHP yolunu ifade eder. Bu ayar Crontab kütüphanesi için de önemlidir. ZN Terminal PHP 7 ve üzeri sürüm istediği için bu ayara sürümü 7 ve üzeri olan geçerli PHP yolu yazılmalıdır. Varsayılan olarak /usr/bin/php ayarlıdır. |
# Yöntemler
Processor::exec(string $command) : scalar |
Processor::driver(string $driver) : this |
Processor::output() : array |
Processor::type() : string |
# Exec (ZN >= 4.0.0)
Çalıştırılacak komut yazılır. Çıktı olarak çalıştırılan komutun sonucu döner.
Parametreler
string $command | Çalıştırılacak komut. |
return string |
Kullanımlar
echo Processor::exec('php -v');
with Zend OPcache v7.0.9, ...
# Driver (ZN >= 4.0.0)
Farklı bir sürücüyü seçmek için kullanılır.
Parametreler
string $driver | Geçerli sürücü adı. |
exec, system, shell | |
return this |
Kullanımlar
echo Processor::driver('shell')->exec('php -v');
PHP 7.0.9 (cli) (built: Jul 20 2016 11:08:23) ...
# Output (ZN >= 4.0.0)
Komut sonra elde edilen çıktıyı dizi türünde döndürür.
Parametreler
return array |
Kullanımlar
Processor::driver('system')->exec('php -v');
output( Processor::output() );
0 => string 'PHP 7.0.9 (cli) (built: Jul 20 2016 11:08:23) ( ZTS )' ( length = 55 )
1 => string 'Copyright (c) 1997-2016 The PHP Group' ( length = 39 )
2 => string 'Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies' ( length = 63 )
3 => string ' with Zend OPcache v7.0.9, Copyright (c) 1999-2016, by Zend Technologies' ( length = 77 )
1 => string 'Copyright (c) 1997-2016 The PHP Group' ( length = 39 )
2 => string 'Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies' ( length = 63 )
3 => string ' with Zend OPcache v7.0.9, Copyright (c) 1999-2016, by Zend Technologies' ( length = 77 )
# Type (ZN >= 4.0.0)
HTTP sunucusu ile PHP arasındaki arayüzün türünü döndürür
Parametreler
return string |
Kullanımlar
Processor::type();
cgi