Sage 10 with Acorn + WP Engine

Posting a solution for making Sage 10 + Acorn work with WP Engine managed hosting. It looks like there is a future proof solution in the works here however the solution below works as expected.

// functions.php

/*
|--------------------------------------------------------------------------
| Fix Sage 10 to work with WP Engine environments
|--------------------------------------------------------------------------
|
| Override Acorn's view cache path to /tmp/sage-cache if the site
| is running on WP Engine environment.
|
| /tmp/sage-cache/framework/cache path should be present in WP Engine
| for Sage 10 to work. You can ask WP Engine support to create this path on new
| install if not present and make it writable.
|
| This is required for Sage 10 to work on WP Engine as the default
| view cache path is /<YourWordPressInstallRoot>/wp-content/cache/acorn/framework/views
| and with that default path, WP Engine doesn't allow PHP user to execute/write files in 
| that directory.
|
| filter ref: https://docs.roots.io/acorn/2.x/directory-structure/#advanced
| is_wpe ref: https://wpengine.com/support/determining-wp-engine-environment/
*/

add_filter('acorn/paths.storage', function ($path) {
    if (function_exists('is_wpe') && is_wpe() == 1) {
        return '/tmp/sage-cache';
    }

    return $path;
});
1 Like

UPDATE

We have been through a bit of turbulence with uptime on our site with WP Engine and Sage based themes. The solution of changing cached / compiled path to /tmp/sage-cache for blade engine breaks when the WP Engine reboots at given point in time. WP Engine supports says this custom behaviour cannot be guaranteed to stay in place on subsequent server reboots and violates their SLA as well.

As next steps, we have considered move to Kinsta as an alternative managed hosting provider.

1 Like

Been with Kinsta for a while now, not a single issue of this sort.

Update:

Current working solution for time being implemented by this awesome developer

I can also confirm this works as of today. Question is: will this continue to work later on?