PHP code example of hub20xx / php-local-server

1. Go to this page and download the library: Download hub20xx/php-local-server library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hub20xx / php-local-server example snippets




$docroot = __DIR__ . '/www';

// by default the server is running on 127.0.0.1:1111
$server = new PhpLocalServer\Server($docroot);

// you can specify the address and port
// in the constructor
$address = '127.0.0.2';
$port = '1234';
$server = new Server($docroot, $address, $port);

// or using the setters
$server = new Server($docroot);
$server->setAddress($address);
$server->setPort($port);

// setting environment variables
$server->setEnvironmentVariable('ENV', 'testing');
$server->setEnvironmentVariable('FOO', 'bar');

// starting the server
$server->start();

// using the server

// stopping the server
$server->stop();

// $server->stop() is called in the destructor in case you omit to stop the server
bash
$ composer