samlitowitz/php-memory

A library to interact with PHP memory limit

Installs: 7

Dependents: 0

Suggesters: 0

Security: 0

Stars: 13

Watchers: 1

Forks: 1

Open Issues: 1

pkg:composer/samlitowitz/php-memory

v1.0.2 2023-08-02 22:34 UTC

This package is auto-updated.

Last update: 2025-10-07 16:56:48 UTC


README

Table of Contents

  1. Installation
  2. Usage

Installation

composer require samlitowitz/php-memory

Usage

use PhpMemory\MemoryLimit;
use PhpMemory\Unit\Binary\Megabyte;
MemoryLimit::set(Size::create(2, new Megabyte()), true);

echo init_get(MemoryLimit::INI_OPTION);
// 1M
use PhpMemory\MemoryLimit;
use PhpMemory\Unit\Byte;
MemoryLimit::set(Size::create(100, new Byte()));

echo init_get(MemoryLimit::INI_OPTION);
// 100

See MemoryLimitTest for more examples.