bhittani / web-server
Run a web server programmatically.
Requires
- php: >=5.6
- symfony/process: *
Requires (Dev)
- phpunit/phpunit: <8
This package is auto-updated.
Last update: 2024-10-28 20:22:00 UTC
README
Run and/or control a web server programmatically.
Install
You may install this package using composer.
$ composer require bhittani/web-server --prefer-dist
Usage
By default, this package offers a php web server that uses the built-in development server.
PHP Web 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');
Public path
<?php $webServer->path('/path/to/www/public');
The default path is set to the directory of the server file.
Host
<?php $webServer->host('127.0.0.1');
The default host is set to
localhost
.
Port
<?php $webServer->port(3000);
The default port is set to
9001
.
URL
<?php $webServer->url('https://localhost');
The default url is set to
http://<host>:<port>
.
API
The following API will be available for any web server adhering to the contract/interface.
Start a web server
<?php $webServer->start();
Stop a web server
<?php $webServer->stop();
Check the running state of a web server
<?php $webServer->isRunning();
Get the path to the server
<?php $webServer->getPath();
Get the URL of the server
<?php $webServer->getUrl();
Changelog
Please see CHANGELOG for more information on what has changed.
Testing
git clone https://github.com/kamalkhan/web-server cd web-server composer install composer test
Contributing
Please see CONTRIBUTING and CONDUCT for details.
Security
If you discover any security related issues, please email shout@bhittani.com
instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see the License File for more information.