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.