Skip to content

Instantly share code, notes, and snippets.

@dfelton
Created August 20, 2019 17:06
Show Gist options
  • Select an option

  • Save dfelton/277a3b053e95bd5070efc84500a95028 to your computer and use it in GitHub Desktop.

Select an option

Save dfelton/277a3b053e95bd5070efc84500a95028 to your computer and use it in GitHub Desktop.
Just a quick and dirty memory limit check.
# PHP Memory Limit Check (converts memory limit to bytes and verifies it is 1 gigabyte or greater)
php -r '(int)preg_replace_callback("/(\-?\d+)(.?)/", function ($m) { return $m[1] * pow(1024, strpos("BKMG", $m[2])); }, strtoupper(ini_get("memory_limit"))) >= 1073741824 ? exit(0) : exit(1);'
if [ $? -eq 0 ]; then
echo -e "\t\e[32mPASS:\e[0m PHP CLI memory limit is configured to 1 Gigabyte or greater"
else
INSTALL_CHECK=0
echo -e "\t\e[91mFAILED:\e[0m PHP CLI memory limit is not configured to 1 Gigabyte or greater"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment