PHP code example of orlandothoeny / memory-limiter
1. Go to this page and download the library: Download orlandothoeny/memory-limiter 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/ */
orlandothoeny / memory-limiter example snippets
use MemoryLimiter\AvailableMemoryReader;
$availableMemoryReader = AvailableMemoryReader::create();
$availableMemory = $availableMemoryReader->determineAvailableMemoryBytes();
use MemoryLimiter\MemoryLimiter;
$memoryLimiter = MemoryLimiter::create();
/* Set memory limit to the currently available memory
Will skip setting the memory limit if running inside a Kubernetes container */
$memoryLimiter->setMemoryLimitToCurrentlyAvailableMemory();
// Also set memory limit when running inside a Kubernetes container
$memoryLimiter->setMemoryLimitToCurrentlyAvailableMemory(false);
// Set memory limit to 50% of the currently available memory
$memoryLimiter->setMemoryLimitToCurrentlyAvailableMemory(
limitToPercentageOfAvailableMemory: 50
);
shell
docker compose exec php sh
shell
docker compose exec php composer test
shell
docker compose exec php composer phpstan
shell
docker compose exec php composer cs-fix
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.