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?
EDIT
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
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?
EDIT
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
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/cli/handbook/config/#environment-variables
exec("whoami")
in PHP it says admin. can you explain how are they different? – Ali Sh Commented Oct 23, 2018 at 4:57hostname
command. – Ali Sh Commented Oct 23, 2018 at 8:17