I have put together a small script to deploy to WPEngine when you use Bedrock and Roots. WPEngine doesn’t support asset building or keeping WordPress in a different directory. The script creates a temporary branch that grabs the packages, dependencies and compiles the assets. It then moves the app folder back to wp-content and removes all other files. The .gitignore files are removed too so the compiled assets are staged. This is then pushed up to staging or production and once completed it’ll remove the branch and you’ll be back on the local working copy.
Feel free to give it a try and hopefully in the future WPE will support the Bedrock workflow.
I just changed it so rather than removing files physically it amends the gitignore and clears the git cache. Otherwise when you change back to the previous branch you would have to re-run composer, npm and bower and that’s just way too time consuming.
I’ve actually removed all the build steps and it assumes that the branch you’ve just checked out of has the latest built files.
Thank goodness for Discourses ‘similar questions’. I mean, how epicly well marketed is Mercury! I was hoping to be able to have the best of both worlds, hopefully with this I can.
I’m really new at Vagrant, how would you set this up? Do you just add the Sage theme into the WPEngine box? As in, after vagrant uping WPEngine?
Wow I’m struggling to make sense so bad right now.
We are talking about different things. This is a script to use Bedrock to deploy to WPEngine by replacing capistrano. It doesn’t matter whether what environment you use. There is nothing stopping you using Bedrock, Sage and Mercury together but my script is not designed for that. It’s designed for going local->staging->production while still using Bedrock.
P.s I was thinking about setting this up with composer as well, so instead of running out the root it runs out the vendor folder but the process remains the same. Does anyone want this?
@JulienMelissas have you tried this out yet? I made a few changes today but pretty sure it works in most use cases now. The first version I released definitely didn’t work on most setups lol
@anon66789415 thanks so much for your great script. I have forked it, credited you in my sh file, and went in a different direction, introducing some flexibility and documentation. Linking here in case anyone is interested.
How do you manage Bedrock autoloaded mu-plugins?
It breaks the site on my install, the autoloader makes some scripts load twice.
The manual solution I came up with is removing bedrock-autoloader.php and requiring the .php files in the plugins folders. Did you manage to automate this?
I’m actually using a modified version of your script to deploy some sites. But those only use Sage, not Bedrock, at least for now…
EDIT:
Maybe Bedrock could exclude WPEngine mu-plugins from the autoloading process. Because the problem is that WPEngine has a mu-plugin that takes care of loading some other scripts inside a subfolder… so Bedrock also loads those and it fails.
Maybe add an option to exclude certain directories?
EDIT 2: The point is that Bedrock Autoloader does work ok. But fails because of how WPEngine loads their mu-plugins.
change all instances of WPMU_PLUGIN_DIR to WPMU_PLUGIN_DIR . '/bedrock/'
You will then need to run composer update and likely delete the plugins within mu-plugins that are leftover and now within the bedrock subfolder (they weren’t auto removed for me).
I literally just got this working, so will report back if it fails, but so far so good.
@inthedeepend I’ve been deploying to a WPEngine staging build without issues yet! Are you deploying with this? https://github.com/hello-jason/bedrock-deploy-to-wpengine If yes, and if you’re also using Trellis, let me know and I’ll help you get that script working (depends how your git repo and folder structure is setup for your Trellis project).
@jamiechong I’m getting the following error on WPEngine PHP Fatal error: Cannot redeclare class Roots\\Bedrock\\Autoloader in /nas/content/live/siteprod/wp-content/mu-plugins/bedrock/bedrock-autoloader.php on line 16
Have you seen this before?