Development console by thekid · Pull Request #35 · xp-forge/web

This pull request adds a development console, which is shown if any output is generated via output, echo or other PHP output functionality. It will show the output as well as the HTTP response generated from the code as seen below.

This enables var_dump()-driven development on an entirely new level.

Application

class Hello extends \web\Application {

  public function routes() {
    return [
      '/' => function($req, $res) {
        // var_dump($req->headers());
        $res->answer(200, 'OK');
        $res->send('Hello World', 'text/plain');
      }
    ];
  }
}

Regular request

image

Request w/ var_dump uncommented

image

Enabling the console

This console is enabled inside the development webserver, which is launched by passing -m develop. If developing inside Apache or PHP-FPM, install the development console by prepending the WEB_SOURCE environment variable pointing to the application class with +xp.web.dev.Console.

/cc @georg94 @mikey179