Skip to content

A modern PHP library to get system information with Enums and Value Objects.

License

Notifications You must be signed in to change notification settings

knotsphp/system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

System

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require GitHub Workflow Status (with event)

A modern PHP library to get system information with Enums and Value Objects.

The goal is to get reliable and consistent system information across different operating systems.

This library use local commands to get the system information and parse the output to ensure consistency.

It also provides a command line utility: sysinfo.

Compatible with MacOS, Linux, and Windows.

This library is still very young and contributions are welcome.

🚀 Installation

composer require knotsphp/system

📚 Usage

use KnotsPHP\System\System;
use KnotsPHP\System\Enums\OperatingSystem;

// Get the operating system
$os_enum = OperatingSystem::current(); // Returns an enum
$os = System::os(); // Returns an instance of OperatingSystemContract

The OperatingSystemContract provides the following methods through the Windows, Linux, and MacOS classes.

// Get basic system information
echo $os->name();           // MacOS    Ubuntu            Windows
echo $os->version();        // 15.2     20.04             10
echo $os->kernel();         // 24.2.0   5.4.0-42-generic  10.0.18363.1316
echo $os->build();          // 24C101   5.4.0-42-generic  21H2

📚 Use in command line

You can also use this library in the command line by using the system command.

It's recommended to install the library globally to use it in the command line.

composer global require knotsphp/system

Then you can use the sysinfo command.

# In your project directory
vendor/bin/sysinfo

# Globally installed
sysinfo

📖 Documentation

This library is compatible with MacOS, Linux, and Windows.

Contributions are welcome to add more operating systems.

📋 TODO

  • Make the Shell class usable through a pipeline to run commands through SSH
  • Add an DataValueObject so the developer can feed raw data and pass it to other libraries
  • Make a Machine class to get more information about the machine
  • Make a Monitor class to get current system usage
  • Make a Network class to get network information

Suggestions are welcome, but please follow these guidelines:

  • Do not add anything that requires elevated access
  • Do not add anything that requires writing to the system
  • Do not add anything that requires installation of additional software

🤝 Contributing

Clone the project and run composer update to install the dependencies.

Before pushing your changes, run composer qa.

This will run pint (code style), phpstan (static analysis), and pest (tests).

👥 Credits

System was created by Eser DENIZ.

📝 License

System is licensed under the MIT License. See LICENSE for more information.

About

A modern PHP library to get system information with Enums and Value Objects.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Languages