Skip to content
utopia-phpPublic

About

Lite & fast micro PHP system library that is **easy to use**.

Topics

Resources

Stars

27 stars

Watchers

5 watching

Forks

Latest commit

 

History

131 Commits

Folders and files

Repository files navigation

Utopia System

Important

This repository is a read-only mirror of packages/system in appwrite/appwrite. Development happens there — please open issues and pull requests against appwrite/appwrite.

Total Downloads Discord

Utopia System library is a simple and lite library to obtain information about the host's system, and provides an easy way to detect on which CPU architecture your code is running. This library is aiming to be as simple and easy to learn and use. This library is maintained by the Appwrite team.

Although this library is part of the Utopia Framework project, it can be used as standalone with any other PHP project or framework that loads the utopia extension — see System requirements.

Getting started

Install using Composer:

composer require utopia-php/system

Init in your application:

<?php

require_once __DIR__ . '/../../vendor/autoload.php';

use Utopia\System\System;

echo System::getOS(); // prints "Linux" for example
echo System::getHostname(); // Your hostname
echo System::getArch(); // x86_64
echo System::getEnv('MY_ENV_VAR'); // test

echo System::isArm(); // bool
echo System::isPPC(); // bool
echo System::isX86(); // bool

System requirements

Utopia System requires PHP 8.4 or later and the utopia extension (ext-utopia, built from crates/extension in appwrite/appwrite). Utopia\System\System comes from the extension; this package holds its signatures for static analysis and editors (stubs/) and the tests. 0.11.x is the last release with the class in PHP.

Supported methods

System::getMemory() returns the effective memory capacity in MiB, rounded down. On Linux, it reads cgroup v2 memory.max or cgroup v1 memory.limit_in_bytes from the standard container mounts under /sys/fs/cgroup, capped at host RAM. It falls back to getMemoryTotal() when a limit is missing, unreadable, or unlimited. On macOS, it returns host RAM. Other operating systems throw an exception. getMemoryTotal() continues to return host RAM.

getCPUCores getCPUUsage getMemoryTotal getMemoryFree getDiskTotal getDiskFree getIOUsage getNetworkUsage
Windows ✅ ✅ ✅
MacOS ✅ ✅ ✅ ✅ ✅
Linux ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅

Authors

Eldad Fux

Torsten Dittmann

Copyright and license

The MIT License (MIT) http://www.opensource.org/licenses/mit-license.php

About

Lite & fast micro PHP system library that is **easy to use**.

Topics

Resources

Stars

27 stars

Watchers

5 watching

Forks

Releases

Used by

Contributors

Languages