Is it possible to prevent LocalWP from editing wp-config.php when it does a pull? Or something similar that would help here…
My wp-config.php file is deliberately version controlled.
I use a .env file (dotenv) and $_ENV['DB_NAME'] to set the constants within wp-config.php. When LocalWP does a pull it tries to update these values and frankly breaks the whole thing.
Does anyone know if it’s possible to prevent Local from either updating some constants or editing the file altogether?
Thank you
wp-config.php is already in the .wpe-pull-ignore file
I swear this didn’t used to happen but I couldn’t say when this behaviour changed
Are you pulling from WP-Engine specifically? Because this only works with WPE and not with Flywheel if you’ve got sites on both or only on FW.
If you’re on WP Engine, make sure your .wpe-pull-ignore file is in your /app/public/ directory, and then Local should ignore any files/paths provided there.
You can also see all of the auto-ignored files on this link here:
What I assume is happening is, as part of LocalWP’s processes when pulling, it searches wp-config.php for the constants (and their values) it needs for the website to run normally. If it doesn’t see what it expects then it add/updates the constants.
If that’s true, it’s this action that’s breaking my setup and what I’d like to prevent.
For extra clarity, these are the changes it makes. It doesn’t realise that the DB consts are already set. Then god knows what it’s doing with WP_HOME & WP_SITEURL before commenting them out.
I realise this is quite an edge case and I can just checkout the changes with git on each pull. But, you know, developers love removing manual tasks. Plus, versioning this file can’t be all that uncommon. Perhaps there’s a solution or workaround out there.
I checked with the Local Devs and looking at the code that updates the WP_HOME and WP_SITEURL constants, that part of Local core hasn’t changed in several years. I know you had mentioned you didn’t think this used to be an issue but we’re just a bit stumped when something may have changed that impacted this. It seems like Local isn’t necessarily editing the wp-config.php file but ignoring it and generating a new one when pulling.
For now at least, you might be correct in that incorporating Git will be the best way to ensure nothing is getting broken.
Ok, I’ll just continue using git to checkout the changes made by Local.
Also, I think it’s best to disregard what I said here. On reflection I’m not sure now:
I swear this didn’t used to happen but I couldn’t say when this behaviour changed
Perhaps if there’s an elegant way to stop the wp-config.php file from being updated, that would be a nice addition to the software . Especially useful for when files are version controlled.