carlosvini/serve2

This package is abandoned and no longer maintained. No replacement package was suggested.

Concurrent alternative to PHP built-in web server.

v0.1.2 2020-05-03 20:28 UTC

This package is auto-updated.

Last update: 2021-12-04 23:05:56 UTC


README

As of 7.4 it's possible to set PHP_CLI_SERVER_WORKERS=N to handle concurrent requests, which makes this package very short lived

This contraption can be used as an alternative to the PHP built-in web server in scenarios where you need more than one connection but for some reason can't install a real web server like NGINX, Apache, Lighttpd or Caddy.

NEVER USE IT IN PRODUCTION.

Not tested on Windows yet.

Installation as a standalone command

It's distributed as a PHAR executable, just like composer.

wget https://github.com/carlosvini/serve2/releases/download/v0.1.2/serve2.phar -O /usr/local/bin/serve2
chmod +x /usr/local/bin/serve2

How to run

cd /my-folder-with-php-code
serve2 

# OR:

serve2 --port 8000

Installation as a Laravel command

If you have auto-discover enabled:

 composer require carlosvini/serve2

Otherwise, manually add "CarlosVini\Serve2\Serve2ServiceProvider" to config/app.php, in the "providers" array.

How to run

php artisan serve2

How it works

It opens PHP servers and forwards the requests to any of them which is less busy. It tries to close the servers on shutdown but it might fail since it's a hack right now. In this case run "pkill php" to kill the unclosed servers.