PHP code example of wyrihaximus / cpu-core-detector

1. Go to this page and download the library: Download wyrihaximus/cpu-core-detector library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

wyrihaximus / cpu-core-detector example snippets

bash
git clone https://github.com/your-user/php-cpu-core-detection.git

 $loop = Factory::create();

Detector::detectAsync($loop)->then(function ($result): void {
    echo $result, \PHP_EOL;
    for ($i = 0; $i < $result; $i++) {
        Resolver::resolve($i, 'uptime')->then(function ($cmd): void {
            echo $cmd, \PHP_EOL;
        });
    }
});

$loop->run();
 

$result = Detector::detect();
echo $result, \PHP_EOL;

for ($i = 0; $i < $result; $i++) {
    Resolver::resolve((string)$i, 'uptime')->then(function ($cmd): void {
        echo $cmd, \PHP_EOL;
    });
}