-
Notifications
You must be signed in to change notification settings - Fork 965
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add global option (--config-path) to specify location of WordPress config file #1218
Comments
Why not use the |
Good thinking. Almost worked. Ran into path issues with the wp-settings.php file (ie. it's not being skipped and throws a "No such file" warning). |
@samstoller mind sharing your setup in a Gist or two (generically, of course, as to not exposing any secrets) so I can play around with it locally? |
Sure thing. The reason for these changes is I've installed WordPress as a git submodule. This requires a bit of modification to how things are normally set up. I will share with you my install process, which may seem a bit convulted at first but it's really quite simple. I also use a custom shell script to deploy so I've automated the entire process. If you search for installing WP as a submodule you will find plenty of developers doing the same thing so it's not such an unsual way of going about installing WP these days as it has many benefits. Here's a simplified version of my install script: https://gist.github.com/samstoller/3f080f65d4126fe5b9c5 Once you've got the correct layout, try using wp-cli and you will find that it struggles with the config file path. To get around this for now, I forked the wp-cli repo, made some hacky changes to the core so it looks in my custom conf/ dir and compiled the tool and everything seems to work pretty well. This lead me to thinking a config path option would work. |
@samstoller apologies for the late reply here. When you attempt to run WP-CLI with your configuration, do you get this error?
From the example you've provided, it appears you might be able to use your existing pattern as long as the existing Related #1362 |
Yes, that's the error I receive. So I tried the idea of tricking WP-CLI into thinking it has found the line with
So I ran a command and got a 'Cannot redeclare' type error and realized that when WP-CLI parses the actual config file it doesn't skip the call to The same issue happened when I tried the Ideally, it would be great to see |
You'll need to remove
Probably not going to happen. |
This is causing issues for me as well, as I have my wp-config in /etc/wordpress and I'm using a stub wp-config to load it from there using require_once. I see that this is closed, but I don't think it's uncommon to want to move the wp-config outside of the web directory. |
Yeah I'm having the same issue as this. I really would like to keep the wp-config outside of a directory that apache can read to. |
As @danielbachhuber said, the stub require_once( ABSPATH . 'wp-settings.php' ); Remove that line from your custom |
Exactly right. I made a gist for this for anyone still having trouble. HTH. |
I know this closed but add another +1 to the request to allow us to define the location of wp-config.php via parameter. |
Another +1. That gist is not helpful at all. I'm not using any sort of a "stub" but if it can't find my wp-config file for some reason, despite being in the same folder I'm running it from, right there alongside my other WP folders, it would be helpful if I could just tell it where it is with a parameter. Without that or a clear set of instructions for what is needed, it is not usable at all. If I could just do something like "wp --help" or "wp -h" to see what the "--require" option you mentioned is, that would be great, but without it being able to find the wp-config file that's sitting right here in this directory that I'm trying to run it from, even that doesn't work. There really should be an easy way to tell it where the file is, since it's that important. EDIT: Problem solved on my own. It took some digging, but for anyone coming here looking for a solution to the same issue, the solution was simple for me: manually adding the line |
My wp-config.php file is located in a non-standard directory levels above wp-content. WordPress is able to locate this file as the standard wp-config.php has been changed to "require()" the actual conf file.
wp-cli is unable to parse my config file as it's just reading the source looking for the constants and wp-setting. So rather than try to parse the PHP code and read the file from the correct location, it would be easier and more flexible to specify a path to the conf file instead.
I'd be happy to work on this and submit a pull request. Thoughts?
The text was updated successfully, but these errors were encountered: