open-southeners/machine-stats
最新稳定版本:1.0.0
Composer 安装命令:
composer require open-southeners/machine-stats
包简介
A platform agnostic machine stats generator (PHP 8.1+). Usage and totals for CPU, disk, memory...
关键字:
README 文档
README
A platform agnostic machine stats generator (PHP 8.1+). Usage and totals for CPU, disk, memory...
Getting started
composer require open-southeners/machine-stats
Usage
use OpenSoutheners\MachineStats\StatsManager; $report = StatsManager::report(); $report->os->value; // 'linux' $report->cpuCores; // 8 $report->cpuUsage; // 17.12 $report->memoryUnit->name; // 'GB' $report->memoryAvailable; // 11.89 $report->memoryUsed; // 4.11 $report->diskUnit->name; // 'GB' $report->diskCapacity; // 200 $report->diskAvailable; // 189 $report->diskUsed; // 11
Using Laravel
If you are using Laravel you can simply inject 2 instances into Laravel's container. Add the following on your AppServiceProvider.php file at the register method:
use OpenSoutheners\MachineStats\StatsManager; use OpenSoutheners\MachineStats\Drivers\DriverInterface; $this->app->bind(StatsManager::class, fn () => new StatsManager); $this->app->bind(DriverInterface::class, fn (Application $app) => $app->make(StatsManager::class)->getDriver());
Note: StatsManager is only a wrapper to the Driver, it mimics the Manager code design pattern that Laravel uses in many places like DB, Filesystem, etc. In our case we needed to separate between operating systems (as drivers).
Partners
License
This package is open-sourced software licensed under the MIT license.
统计信息
- 总下载量: 12
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-10-30
