I installed this package on WP-CLI. When I run wp login create in bash it works fine, but when I run exec("wp login create") in PHP script WP-CLI return this error:

Error: 'login' is not a registered wp command. See 'wp help' for available commands.

Did you mean 'plugin'?

I checked the user from exec("whoami") and it's the same. How can I find the problem?


when I run wp package list in PHP it returns:

Error: Composer directory '/.wp-cli/packages' for packages couldn't be created: mkdir(): Permission denied

  • 1
    You might get different result because you are running the commands under different user.
    – Thomas
    Commented Oct 22, 2018 at 12:40
  • but I run the command in bash with a user named admin@server and when I run exec("whoami") in PHP it says admin. can you explain how are they different?
    – Ali Sh
    Commented Oct 23, 2018 at 4:57
  • is the group also the same?
    – Thomas
    Commented Oct 23, 2018 at 7:31
  • yes it is the same. I checked with hostname command.
    – Ali Sh
    Commented Oct 23, 2018 at 8:17

1 Answer 1


According to Alain Schlesser in wordpress slack:

The folder that the packages are installed into is set to use your server user's home folder. When you try to execute this command from PHP, however, it is being executed by the webserver's user, which probably has a different home folder, and the package is not installed in there.

You can either load the package manually as part of the system (requiring it in the site's Composer stack, for example), or set the package folder to a location that is shared by both your user and your webserver (and reinstall it afterwards).

You can set the packages folder with the WP_CLI_PACKAGES_DIR environment variable: https://make.wordpress.org/cli/handbook/config/#environment-variables

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.