decodelabs / systemic
轻松访问系统和环境信息
v0.11.14
2024-08-21 20:41 UTC
Requires
- php: ^8.1
- ext-intl: *
- decodelabs/archetype: ^0.3
- decodelabs/coercion: ^0.2
- decodelabs/deliverance: ^0.2.9
- decodelabs/eventful: ^0.3.4
- decodelabs/exceptional: ^0.4
- decodelabs/fluidity: ^0.3
- decodelabs/glitch-support: ^0.4
- decodelabs/veneer: ^0.11.6
- symfony/polyfill-mbstring: ^1.7
Requires (Dev)
- dev-develop / 0.11.x-dev
- v0.11.14
- v0.11.13
- v0.11.12
- v0.11.11
- v0.11.10
- v0.11.9
- v0.11.8
- v0.11.7
- v0.11.6
- v0.11.5
- v0.11.4
- v0.11.3
- v0.11.2
- v0.11.1
- v0.11.0
- v0.10.5
- v0.10.4
- v0.10.3
- v0.10.2
- v0.10.1
- v0.10.0
- v0.9.7
- v0.9.6
- v0.9.5
- v0.9.4
- v0.9.3
- v0.9.2
- v0.9.1
- v0.9.0
- v0.8.3
- v0.8.2
- v0.8.1
- v0.8.0
- v0.7.1
- v0.7.0
- v0.6.13
- v0.6.12
- v0.6.11
- v0.6.10
- v0.6.9
- v0.6.8
- v0.6.7
- v0.6.6
- v0.6.5
- v0.6.4
- v0.6.3
- v0.6.2
- v0.6.1
- v0.6.0
- v0.5.0
- dev-main
This package is auto-updated.
Last update: 2024-09-04 21:34:16 UTC
README
系统进程和信息触手可及
Systemic 提供了一个易于使用的界面,用于启动和控制系统进程以及访问系统信息。
在DecodeLabs 博客上获取新闻和更新。
安装
通过 Composer 安装
composer require decodelabs/systemic
用法
导入
Systemic 使用 Veneer 在 DecodeLabs\Systemic
下提供一个统一的界面。您可以通过这个静态界面访问所有主要功能,而不会影响测试和依赖注入。
进程启动
启动新进程
use DecodeLabs\Systemic; $dir = 'path/to/working-directory'; // Launch and capture output of a process echo Systemic::capture(['ls', '-al'], $dir)->getOutput(); // Launch and capture output of a process with raw string command (not escaped) echo Systemic::capture('ls -al', $dir)->getOutput(); // Launch and capture output of a script echo Systemic::capture(['myPhpScript.php'], $dir)->getOutput(); // Launch a background task $process = Systemic::launch(['make', 'install']); // Launch a background script $process = Systemic::launchScript(['myPhpScript.php'], $dir); // Run a piped pseudo terminal process $success = Systemic::run(['interactive-app', '--arg1'], $dir); // Run a piped pseudo terminal script $success = Systemic::runScript(['myPhpScript.php', '--arg1'], $dir); // Custom escaped command $success = Systemic::command(['escaped', 'arguments']) ->setWorkingDirectory($dir) ->addSignal('SIGSTOP') // Pass SIGSTOP through when caught ->setUser('someuser') // Attempt to use sudo to run as user ->run(); // Custom raw command with env arguments $result = Systemic::command('echo ${:VARIABLE} | unescaped-command', [ 'VARIABLE' => 'Hello world' ]) ->setWorkingDirectory($dir) ->capture();
操作系统信息
获取当前操作系统的信息
use DecodeLabs\Systemic; // OS info echo Systemic::$os->getName(); // Linux | Windows | Darwin echo Systemic::$os->getPlatformType(); // Unix | Windows echo Systemic::$os->getDistribution(); // eg Ubuntu or High Sierra, etc echo Systemic::$os->getVersion(); // System version info echo Systemic::$os->getRelease(); // System version number echo Systemic::$os->getHostName(); // System hostname // Find binaries on the system echo Systemic::$os->which('php'); // eg /usr/local/bin/php
Windows
请注意,Windows 上的操作系统和进程支持目前非常不稳定 - 这将在不久的将来完善!
区域设置 & 时区
寻找区域设置和时区信息?这已移至 Cosmos。
许可
Systemic 使用 MIT 许可证。有关完整的许可证文本,请参阅 LICENSE。