I was building a new feature on Aryeo that allows users to save their flyer creation process, when I encountered an error on our staging server:
PHP Warning: Unknown: POST Content-Length of 25923563 bytes exceeds the limit of 8388608 bytes in Unknown on line 0
I was trying to upload a 25MB flyer, but out default PHP max post size was only 8MB. No problem I’ll just update the PHP INI file….oh wait, Heroku doesn’t let you do this. They outline a number of solutions in their docs however: https://devcenter.heroku.com/articles/custom-php-settings
After a bit of research and trying their .user.ini file in the root directory, I still couldn’t get my dyno to accept the new settings. It seems this was happening for others, as well as some confusion over the placement of the file in either the public/ root or the application root.
I created a user.ini file in the root of my application, aka next to my Procfile. I also didn’t prepend a “.” to the file name, as I ran into problems detecting this file. Here’s what the file consisted of:
upload_max_filesize = 25M
post_max_size = 25M
I then also updated my Procfile (after numerous application failures due to wrong ordering):
web: vendor/bin/heroku-php-apache2 -i user.ini public/
The -i directive tells PHP to load additional ini variables found in the specified file. Note you must direct this before the “public/”. Heroku documentation says that the build should auto-detect the user.ini file, but I found only this to work. Please comment if you have a better solution!