mirror of
https://github.com/php/frankenphp.git
synced 2026-03-24 00:52:11 +01:00
fix: exit() and dd() support in worker mode (#1946)
* Verifies exit behavior. * formatting * Checks for actual exit. * Fixes test. * Fixes test. * Update testdata/dd.php Co-authored-by: Kévin Dunglas <kevin@dunglas.fr> --------- Co-authored-by: Kévin Dunglas <kevin@dunglas.fr>
This commit is contained in:
committed by
GitHub
parent
fb1f46808e
commit
bf6e6534f6
32
testdata/dd.php
vendored
Normal file
32
testdata/dd.php
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
// simulate Symfony's dd() behavior
|
||||
// see https://github.com/symfony/http-kernel/blob/7.3/DataCollector/DumpDataCollector.php#L216
|
||||
class Dumper
|
||||
{
|
||||
private string $message;
|
||||
|
||||
public function dump(string $message): void
|
||||
{
|
||||
http_response_code(500);
|
||||
$this->message = $message;
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
if (isset($this->message)) {
|
||||
echo $this->message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$dumper = new Dumper();
|
||||
|
||||
while (frankenphp_handle_request(function () use ($dumper) {
|
||||
$dumper->dump($_GET['output'] ?? '');
|
||||
exit(1);
|
||||
})) {
|
||||
// keep handling requests
|
||||
}
|
||||
|
||||
echo "we should never reach here\n";
|
||||
Reference in New Issue
Block a user