I'm using Heroku to host a Craft 3 site, and it's working fine, apart from the fact that Craft isn't able to write to the /storage folder (or anywhere else, for that matter). Consequently, the Database Backup utility doesn't work and nor is Craft able to write logs. I'm keen to fix both these issues.

Has anyone managed to solve this problem on Heroku? If so, how?


For anyone else trying this: the solution I eventually came up for was to follow these instructions for adding an argument to the Procfile to tell Heroku to tail Craft's log file into the "Logplex" stream.

There might well be situations where Brad's suggestion (using a plugin to write the logs to stderr) is preferable, but I wasn't sure what the implications would be for logs in development (where it's fine for them to be written to the file system). Adding an argument to the Procfile side-steps this issue, since it's only run by Heroku.

My Procfile now looks like this:

web: vendor/bin/heroku-php-nginx -C nginx_app.conf -l storage/logs/web.log web
  • Nick, did this resolve the database backup issue? Also, would you consider sharing your nginx_app.conf? Trying to make craftcms work with nginx...
    – aaandre
    Jan 23 '20 at 21:50

Not super familiar with Heroku, but some Googling suggests and if you want to keep anything on a permanent (non-ephemeral) file system, most people use S3 for that.

There is the CRAFT_STORAGE_PATH PHP constant for both Craft 2 and 3, but it's currently assuming local file-system based paths and making it cloud based would cause a big performance hit anyway.

You're probably better off solving this with plugins.

Specifically things like this for logs: https://github.com/ostark/craft-stderr-logger

And database backup plugins that have the option to write to S3.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.