I\'m need to check if memory_limit
is at least 64M
in my script installer. This is just part of PHP code that should work, but probably due to this
Thank you for inspiration.
I had the same problem and instead of just copy-pasting some function from the Internet, I wrote an open source tool for it. Feel free to use it or provide feedback!
https://github.com/BrandEmbassy/php-memory
Just install it using Composer and then you get the current PHP memory limit like this:
$configuration = new \BrandEmbassy\Memory\MemoryConfiguration();
$limitProvider = new \BrandEmbassy\Memory\MemoryLimitProvider($configuration);
$limitInBytes = $memoryLimitProvider->getLimitInBytes();
If you are interested in CLI memory limit:
cat /etc/php/[7.0]/cli/php.ini | grep "memory_limit"
FPM / "Normal"
cat /etc/php/[7.0]/fpm/php.ini | grep "memory_limit"
Command line to check ini:
$ php -r "echo ini_get('memory_limit');"