Can I run WP-CLI https://wp-cli.org/ command through PHP script, so I can install user selected WordPress themes automatically with PHP script
2 Answers
As long as you can use the exec() or similar command. I use something like this to output the result of a wp-cli command:
<pre>
<?php
exec("wp --info", $result);
echo implode(PHP_EOL, $result); // join multi-line return result
?>
</pre>
Or simply:
<?php exec("wp --info");
See this answer: https://wordpress.stackexchange.com/questions/219230/utilize-wp-cli-from-inside-wordpress-not-ssh for further discussion.