Run and/or control a web server programmatically.
You may install this package using composer.
$ composer require bhittani/web-server --prefer-dist
By default, this package offers a php web server that uses the built-in development server.
This uses the built-in development server.
<?php
require_once __DIR__ . '/vendor/autoload.php';
$webServer = new \Bhittani\WebServer\Php('/path/to/www/public/index.php');
<?php
$webServer->path('/path/to/www/public');
The default path is set to the directory of the server file.
<?php
$webServer->host('127.0.0.1');
The default host is set to
localhost
.
<?php
$webServer->port(3000);
The default port is set to
9001
.
<?php
$webServer->url('https://localhost');
The default url is set to
http://<host>:<port>
.
The following API will be available for any web server adhering to the contract/interface.
<?php
$webServer->start();
<?php
$webServer->stop();
<?php
$webServer->isRunning();
<?php
$webServer->getPath();
<?php
$webServer->getUrl();
Please see CHANGELOG for more information on what has changed.
git clone https://github.com/kamalkhan/web-server
cd web-server
composer install
composer test
Please see CONTRIBUTING and CONDUCT for details.
If you discover any security related issues, please email shout@bhittani.com
instead of using the issue tracker.
The MIT License (MIT). Please see the License File for more information.