PHP Runtime class provides methods to get total and free memory and number of available processors.
composer require akondas/php-runtime
use Akondas\Runtime;
$runtime = new Runtime();
$runtime->totalMemory();
$runtime->freeMemory();
$runtime->availableProcessors();
PHPRuntime is released under the MIT Licence. See the bundled LICENSE file for details.