bhittani/web-server

Run a web server programmatically.

0.2.0 2020-03-28 10:24 UTC

This package is auto-updated.

Last update: 2024-03-28 19:04:36 UTC


README

Travis Build Status Packagist Downloads License

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.