Statix Server is an Object-oriented Wrapper for PHP's Built-in Server

Admin   Laravel   362  2022-08-05 22:00:02

Statix Server is an object-oriented wrapper around PHP's built-in server. Once you install the composer package, getting started is as minimal as the following:

1use Statix\Server\Server;
2 
3require_once './vendor/autoload.php';
4 
5Server::new()->start();
6 
7// or
8(new Server)->start();

The server class has an array-based configuration of options, or you can use the class' fluent API:

1Server::new()
2 ->usePHP('path')
3 ->onHost('localhost')
4 ->onPort('8080')
5 ->root('./content')
6 ->useRouter('./router.php')
7 ->withEnvVars([
8 'APP_DYNAMIC_ENV' => 'server'
9 ])->withoutEnvVars([
10 'APP_KEY',
11 ]);

It also supports use-cases like capturing server output, running in the background and programmatically stopping the server.

You can learn about this package, get full installation instructions, and view the source code on GitHub. This package uses PestPHP if you want to see an example in the wild of using Pest for testing!

Source: laravel-news.com