Edit Apache and mod_php


Apache + mod_php is a traditional way to use php on the web. You can use the php\webserver\WebServer class from the jphp-webserver-ext extension if you want to develop a web application with JPHP, you do not need to use Apache, Ngnix or something else to implement a web app with JPHP.

WebServer is an embedded server which implemented with Tomcat, Jetty and Spring Boot. We will consider how to use the webserver classes to run your web app implemented with pure PHP.

WebServer

The next example will be more clear if you know how to implement an http server in node.js:

use php\webserver\WebServer;
use php\webserver\WebRequest;
use php\webserver\WebResponse;

// set the route callback for http requests
$server = new WebServer(function(WebRequest $request, WebResponse $response) {
       echo "Hello World!";
});

$server->port = 8080; // http port, localhost:8080
$server->isolated = true; // each request will be executed in an isolated environment
$server->hotReload = true; // each request will be executed in an environment with the hot reload option

// finally run
$server->run();

After this, your app will be available at the http://localhost:8080/ url.