PHP code example of igniphp / network

1. Go to this page and download the library: Download igniphp/network 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/ */

    

igniphp / network example snippets



// Autoloader.
stance.
$server = new \Igni\Network\Server();
$server->start();

 
 // Autoloader.
 ver\Client;
 use Igni\Network\Server\OnRequestListener;
 use Psr\Http\Message\ServerRequestInterface;
 use Psr\Http\Message\ResponseInterface;
 use Igni\Network\Http\Stream;
 
 // Create server instance.
 $server = new \Igni\Network\Server();
 
 // Each request will retrieve 'Hello' response
 $server->addListener(new class implements OnRequestListener {
     public function onRequest(Client $client, ServerRequestInterface $request, ResponseInterface $response): ResponseInterface {
        return $response->withBody(Stream::fromString("Hello world"));
     }
 });
 $server->start();
 


// Autoloader.
ost at port 80.
$configuration = new \Igni\Network\Server\Configuration('0.0.0.0', 80);

// Create server instance.
$server = new \Igni\Network\Server($configuration);
$server->start();


// Autoloader.
w \Igni\Network\Server\Configuration();
$configuration->enableSsl($certFile, $keyFile);

// Create server instance.
$server = new \Igni\Network\Server($configuration);
$server->start();


// Autoloader.
w \Igni\Network\Server\Configuration();
$configuration->enableDaemon($pidFile);

// Create server instance.
$server = new \Igni\Network\Server($configuration);
$server->start();

brew install homebrew/php/php71-swoole
composer install igniphp/network