PHP code example of dev-hvmnd / memory-info

1. Go to this page and download the library: Download dev-hvmnd/memory-info 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/ */

    

dev-hvmnd / memory-info example snippets




use DevHvmnd\MemoryInfo\MemoryDataReader;
use DevHvmnd\MemoryInfo\MemoryInfoReadException;

$reader = new MemoryDataReader();

try {
    $memoryInfo = $reader->getMemoryInfo();

    echo $memoryInfo->memTotal;
    echo $memoryInfo->memAvailable;
} catch (MemoryInfoReadException $exception) {
    // Handle missing /proc/meminfo, unreadable data, or unsupported field sets.
}

$memoryInfo = (new MemoryInfoParser())->parse($contents);
shell
docker run --rm -v "$PWD":/app -w /app php:8.2-cli sh -lc '
  export DEBIAN_FRONTEND=noninteractive &&
  apt-get update &&
  apt-get install -y unzip &&
  php -r "copy(\"https://getcomposer.org/installer\", \"/tmp/composer-setup.php\");" &&
  php /tmp/composer-setup.php --install-dir=/tmp --filename=composer &&
  /tmp/composer install &&
  /tmp/composer validate --strict &&
  /tmp/composer check
'