PHP Classes

PHP System Process List: Retrieve the processes running on the system

Recommend this page to a friend!
  Info   View files Example   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 53%Total: 487 All time: 5,897 This week: 78Up
Version License PHP version Categories
process-list 1.0.0BSD License5.5PHP 5, System information, Unix, Windows


This class can retrieve the processes running on the system.

It can perform queries on the current OS to retrieve the list of processes independently of the OS.

The class objects can be iterated like an array, so you can get each process id, command name and parameters, CPU time, start time, title and tty, and children processes.

The process list can be retrieved again using the Refresh function.

It uses WMI queries on Windows and the POSIX call on Linux and Unix like systems.

Innovation Award
PHP Programming Innovation award nominee
October 2016
Number 3

Prize: One subscription to the PDF edition of the PHP Architect magazine
Processes are programs running on the current computer operating system.

Different systems manage and access the data of each process in different ways.

This class provides a platform independent solution to retrieve the list of processes and their details running either on Windows or Linux and other Unix-like systems.

Manuel Lemos
Picture of Christian Vigh
  Performance   Level  
Name: Christian Vigh <contact>
Classes: 32 packages by
Country: France France
Age: 58
All time rank: 13710 in France France
Week rank: 13 Up1 in France France Up
Innovation award
Innovation award
Nominee: 20x

Winner: 3x



        This example demonstrates the use of the ProcessList class.
        It works the same way for both Windows and Unix platforms.


    // This package requires the Wmi package for Windows platforms :
    // A version of this package is provided here for convenience, but it may not be the latest release.
require_once ( 'Wmi.phpclass' ) ;

    require_once (
'ProcessList.phpclass' ) ;

    if (
php_sapi_name ( ) != 'cli' )
        echo (
"<pre>" ) ;

// Get the process list and print it
$ps = new ProcessList ( ) ;
    foreach (
$ps as $process )
print_r ( $process ) ;
        echo (
"\n" ) ;



The ProcessList class provides a platform-independent way to retrieve the list of processes running on your systems. It works both on the Windows and Unix platforms.


To retrieve the list of processes currently running on your system, simply use the following :

require ( 'ProcessList.phpclass' ) ;

$ps 	=  new ProcessList ( ) ;

The $ps variable can now be accessed as an array to retrieve process information, which is simply an object of class Process :

foreach  ( $ps  as  $process )
	echo ( "PID : {$process -> ProcessId}, COMMAND : {$this -> Command}" ) ;

Whether you are running on Windows or Unix, the properties exposed by the Process objects remain the same (see the Reference section).


For Windows platforms, you will need the following package :

A copy of the source code is provided here for your convenience, but it may not be the latest release...


ProcessList class

The ProcessList class is a container class that allows you to retrieve information about individual processes. It implements the ArrayAccess and Iterator interfaces, so that you can loop through each process currently running on your system.

Each element of a ProcessList array is an object of class Process.


public function  __construct  ( $load = true ) ;

Creates a process list object. If the $load parameter is true, the process list will be retrieved ; otherwise, you will need to call the Refresh() method later before looping through the list of available processes.


public function  GetProcess ( $id ) ;

Searches for a process having the specified $id.

Returns an object of class Process if found, or false otherwise.


public function  GetProcessByName ( $name ) ;

Searches for a process having the specified name. The name is given by the Command property of the Process object.


public function  GetChildren ( $id ) ;

Returns the children of the specified process, or an empty array if $id does not specify a valid process id.


public function  Refresh ( ) ;

Refreshes the current process list. This function can be called as many times as desired on the same ProcessList object.

Process class

The Process class does not contain methods, but simply expose properties that contain information about a process.

Argv property

Contains the command-line arguments of the process. As for C (and PHP) programs, Argv[0] represents the command path.


Command name, without its leading path.


Full command line, including arguments.


CPU time consumed by the process, in the form "hh:mm:ss".


Dd of the parent process for this process.


Process id of the current process.


Process start time, in the form "yyyy-mm-dd hh:mm:ss".


Process title. On Windows systems, it will be the title of the process. Since there is no notion of process title on Unix systems, it will be set to the value of the Command property.


Attached tty. This information is useful mainly for Unix systems.

User property

User name running the process. On Unix systems, this can be either a user name or a user id.

  Files folder image Files  
File Role Description
Accessible without login Plain text file example.php Example Example script
Plain text file ProcessList.phpclass Class Class source
Accessible without login Plain text file Doc. Documentation
Plain text file Wmi.phpclass Class Class source 9KB
Downloadprocess-list-2016-10-24.tar.gz 8KB
Install with ComposerInstall with Composer
Needed packages  
Class DownloadWhy it is needed Dependency
Windows PHP WMI Class Download .zip .tar.gz Required on Windows platforms Conditional
 Version Control Unique User Downloads Download Rankings  
This week:0
All time:5,897
This week:78Up
 User Ratings  
 All time