Code Monkey home page Code Monkey logo

Comments (9)

chesio avatar chesio commented on June 7, 2024 1

Hi,

I run into the same problem, $argv seems to be always NULL when I run wp-cli on my development server.

I resorted to specify environment via environment variable: WP_ENV=development wp-cli core version. Maybe it helps someone.

from wordpress-multi-env-config.

simonrjones avatar simonrjones commented on June 7, 2024

Thanks, I think the "Define site host" section needs swapping with the WP-CLI section.

$argv can be checked for, but as far as I'm aware it should always exist in CLI mode.

If you do have any PR please do submit.

best wishes,
Simon

from wordpress-multi-env-config.

davide101 avatar davide101 commented on June 7, 2024

Hi leesherwood, I am definitely interested if you have a solution to #3. I'm automating the process of exporting our production database and bringing it to a dev folder on the same server. Now I need to ensure that WP-CLI targets the correct database when doing Search & Replace to change to the dev account. (Already had an issue with updating production by mistake - easy to undo, thankfully - and want to make this process foolproof.)

from wordpress-multi-env-config.

simonrjones avatar simonrjones commented on June 7, 2024

@davide101 can you please add some example commands that you're using where you cannot pass the --env argument just so I fully understand the need for resolving this issue.

from wordpress-multi-env-config.

davide101 avatar davide101 commented on June 7, 2024

Sure. Here is an example below.

wp search-replace --url=www.examplw.com dev.example.com www.example.com --precise --env=development

Error: Parameter errors:
 unknown --env parameter

Thank you very much for sharing this code. It saved a good bit of time in setting up our dev environment. We very much appreciate it!

from wordpress-multi-env-config.

leesherwood avatar leesherwood commented on June 7, 2024

Hi @davide101. Ultimately we can't change wp-cli behaviour. We could create a wrapper php invoker for wp-cli but as a public solution that's pretty aweful.

In the end i used phpdotenv library to load the data from a private .env file (if you're using things like composer and modern php frameworks you'll be aware of how this works). However by default wordpress isn't setup with composer and requiring users to install a library seems a little OTT.

I think the best thing to do is a hybrid of the existing solution with .env overrides. (I personally would drop the existing solution and make it pure .env controlled, but the existing solution does have its benefits to more junior programmers as it's easier to understand, guess its a matter of personal opinion).

Anyway, i do have a solution that works for me. If @simonrjones likes, i'm happy to make a version of my solution thats not composer dependant and create a PR that addresses all the issues from my original post, however it's more than just a small tweak and might be better served as a second solution (especially if this is the way studio24 prefer to do it).

I'll leave it up to @simonrjones as to whether he wants me refactoring his solution or not :P

from wordpress-multi-env-config.

simonrjones avatar simonrjones commented on June 7, 2024

Sorry for the long delay in replying here.

hi @leesherwood, if you have example code would be interested to see it.

I think I understand in principle, that sometimes it's just not possible to set --env in WP-CLI, and using something like .env file makes more sense. If it's just for setting the environment that's simple enough to integrate without the whole phpdotenv library.

I am currently reviewing a v2 release since am refactoring a few things, making this a bit more secure, best practise, so will review this too.

from wordpress-multi-env-config.

newtlabs avatar newtlabs commented on June 7, 2024

Hi, any update on getting this to work with wp-cli?

from wordpress-multi-env-config.

simonrjones avatar simonrjones commented on June 7, 2024

$argv value has been fixed in the recent update to this code.

If you cannot use --env then please use environment variables as suggested. Another alternative is to create a .env file with the current environment set within it.

from wordpress-multi-env-config.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.