这是一个php脚本,可以执行wp cli,将文件保存在wp admin/文件夹中,并访问www.example-wordpress。com/wp admin/execute\\u cli。php来运行脚本。这只是出于测试目的,不是一种好的使用方法。
执行\\\\u cli。php
<?php
error_reporting(E_ALL | E_STRICT);
ini_set(\'display_errors\', \'1\');
echo "<PRE>\\n";
if(!defined(\'STDIN\')) define(\'STDIN\', fopen(\'php://stdin\', \'r\'));
if(!defined(\'STDOUT\')) define(\'STDOUT\', fopen(\'php://stdout\', \'w\'));
if(!defined(\'STDERR\')) define(\'STDERR\', fopen(\'php://stdout\', \'w\'));
echo "Started\\n\\n";
$return_status = false;
$output = array();
//$executable = \'/path/to/php-executable -c /path/to/php.ini -d error_reporting="E_ALL & ~E_NOTICE" -d memory_limit="2048M" -d max_execution_time=43200 wp-cli.phar \';
//Redirect stdERR so we see warnings/errors
$suffix = \' 2>&1\';
//echo \'Built executable=\'.$executable."\\n";
//$command = \'user delete johnsmithfake --network --yes\';
$command = \'wp core update\';
//$full_command = $executable.$command.$suffix;
$full_command = $command.$suffix;
echo "About to execute command=\\n{$full_command}\\n";
exec($full_command, $output, $return_var);
echo "---------------\\n";
echo implode("\\n", $output)."\\n";
echo "---------------\\n";
echo "Return status (false/0 is success)=".($return_status?1:0)."\\n";
echo "\\nDone</PRE>\\n";