Archive Old post. Originally published 10 December 2013 on the WordPress version of this site. Preserved here for the search engines and the curious. Old me had opinions.
Developer 2 min read

Quick Tip: Increase PHP CLI memory limits

I keep running into memory issues when running pretty intensive scripts from the PHP CLI especially when generating API documentation etc. Now if you don’t want to go and edit your php.ini you can simply add a runtime variable to increase your memory limit. It’s all thanks to the -d or -define option.

This option allows you to set a custom value for any of the configuration directives allowed in php.ini. PHP Documentation

An example would be:

php -d memory_limit=256M my_memory_heavy_script.php

You can also override any other options set in your php.ini.


Filed under Developer. No comments, on purpose.