Laravel’s artisan Won’t Start

Disclaimer: This is as edge as a case can be. I’m writing about it mainly for my future self, but also so you can have a laugh…

I’m working on a small update for a client that requires testing with limited memory available for php. This is because the update is about fixing a memory exhaustion issue in a cron job. The project uses Laravel.

In order to limit the memory, the quickest, and easiest way, is to use ini_set('memory_limit', '100M'). In my case, I want to limit the memory for an artisan command, which is where the memory exhaustion issue is happening, so I added that line to the main artisan file. Instead of 100M, I set it to 30M because I really want to run on very low memory, and 30M is the lowest I can go while ensuring the process has enough memory to start, but not to finish. 30 MB of memory is not a realistic amount of memory for any server, but my local test data is not as big as the data in the upper environments, and I want the job to fail fast, so I need to lower the memory limit to such a low value to ensure the process dies as soon as possible, but not earlier. Otherwise, I would have to sit for over an hour every time I want to test any changes I make.

Anyhow. I tried to run Laravel tinker, and it would not start. I spent some time scratching my head, and looking for a reason, only to later realize that I had not removed the ini_set call in the main artisan file. What a FACEPALM! I consider this to be a variation of when you forget to save the file, and then wonder why your changes are not being applied, which, by the way, has happened to me more times than I’m comfortable admitting.