Is it possible to use WP-CLI via PHP-framework?

The WP_CLI class has a runcommand method that launches a new child process to run a specified WP-CLI command. According to the docs, you can use it like this:

$options = array(
  'return'     => true,   // Return 'STDOUT'; use 'all' for full object.
  'parse'      => 'json', // Parse captured STDOUT to JSON array.
  'launch'     => false,  // Reuse the current process.
  'exit_error' => true,   // Halt script execution on error.
);

$plugins = WP_CLI::runcommand( 'plugin list --format=json', $options );

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)