hugsbrugs/php-scripts

There is no license information available for the latest version (0.1.0) of this package.

PHP Scripts Utilities

0.1.0 2017-04-05 12:34 UTC

This package is auto-updated.

Last update: 2022-09-25 12:04:01 UTC


README

This librairy provides utilities function to ease scripts manipulation

Build Status Coverage Status

Install

Install package with composer

composer require hugsbrugs/php-scripts

In your PHP code, load library

require_once __DIR__ . '/../vendor/autoload.php';
use Hug\Scripts\Scripts as Scripts;

Usage

Run a script, output is saved to log file

$cmd = 'ls -lsa';
$log_file = __DIR__ . '/test.log';
$res = Scripts::run($cmd, $log_file);

Outputs

[status] => success
[message] => 
[data] => Array
(
    [pid] => 3358
    [log] => /path/to/test.log
)

And file /path/to/test.log contains output of ls -lsa command

Checks if a script is running

$running = Scripts::is_running($res['data']['pid']);

Get Memory and processor usage for a script

$cpu_mem = Scripts::get_pid_cpu_mem($res['data']['pid']);

outputs

[mem] => 0.2
[cpu] => 0.1

Unit Tests

composer exec phpunit

Author

Hugo Maugey visit my website ;)