如何解决使用 PSR-RequestHandlerInterface,返回错误,没有错误日志我哪里做错了?
我试过转换这个
require 'vendor/autoload.php';
ini_set('memory_limit','1G');
set_time_limit(300); // 5 minutes execution
use Composer\Console\Application;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\BufferedOutput as Output;
use Symfony\Component\Console\Output\OutputInterface;
putenv('COMPOSER_HOME=' . __DIR__ . '/vendor/bin/composer');
$cikis = new Output;
$giris = new ArrayInput([
'command' => 'remove','packages' => ['trying/trying'],'--working-dir' => getcwd(),]);
$application = new Application();
$application->setAutoExit(false);
$application->run($giris,$cikis);
echo $input;
echo '<hr>';
echo '<pre>' . $cikis->fetch() . '</pre>';
路由到 PSR-RequesthandlerInterface 兼容版本。我是这样写的
namespace xxx\xxx;
use Illuminate\Support\Arr;
use Laminas\Diactoros\Response\HtmlResponse;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Server\RequestHandlerInterface;
use Composer\Console\Application;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\BufferedOutput as Output;
use Symfony\Component\Console\Output\OutputInterface;
use xxxoterpackage\xxothername
class xxxx implements RequestHandlerInterface {
protected $view;
public $packadi;
public $SiteAnaSayfa;
public $komut;
public function __construct($view)
{
$this->view = $view;
}
public function handle(Request $request): Response
{
if (Arr::post($request->getQueryParams(),'packadi') != NULL && Arr::post($request->getQueryParams(),'komut') != NULL)
{
$this->$packadi = Arr::post($request->getQueryParams(),'packadi');
$this->$komut = Arr::post($request->getQueryParams(),'komut');
$this->yap();
$SiteAnaSayfa = app(Paths::class)['base'];
return new JsonResponse({'cikis',$view->render()});
}
}
public function yap() {
if (null !== $request->getAttribute('actor')->assertAdmin()) {
if (isset($this->packadi)) {
ini_set('memory_limit','1G');
set_time_limit(300); // 5 minutes execution
putenv('COMPOSER_HOME=' . $SiteAnaSayfa . '/vendor/bin/composer');
$output = new Output;
$input = new ArrayInput([
'command' => $this->$komut,'packages' => [$this->$packadi],'--working-dir' => $SiteAnaSayfa,]);
$application = new Application();
$application->setAutoExit(false);
$application->run($input,$output);
$cikis = '<hr>';
$cikis .= '<pre>' . $output->fetch() . '</pre>';
$view = $this->view->make($cikis);
}
}
}
}
当我路由它时,它返回错误页面(路由它到达这个类没有错误)我正在检查日志文件,但没有显示错误。我做错了吗。这是我第一次使用这个的经验。而且我的 php 知识很低,无法理解错误的东西。但我正在努力学习。
编辑我忘记解释错误页面的外观
{
"type": "error","content": [
"Oops! Something went wrong. Please reload the page and try again."
],"controls": false
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。