PHP Classes

Simple React PHP HTTP Server: Pure PHP HTTP server using ReactPHP library

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 115 All time: 9,571 This week: 47Up
Version License PHP version Categories
reactphp-simple-http 1.0.0Shareware5HTTP, PHP 5, Social Networking
Description 

Author

This package implements a pure PHP HTTP server using ReactPHP library.

It can start listening to HTTP requests on a given IP address and port number and processes the request by calling code that generates the HTTP responses.

Applications may register listener functions or controller classes to handle specific types of events like errors, requests sent to given URL path patterns, or form submission handling.

Innovation Award
PHP Programming Innovation award nominee
February 2021
Number 7
ReactPHP is a popular PHP library that can be used to develop application using asynchronous programming.

This allows applications to make more efficient use of the server machine CPUs, by executing tasks in parallel, while other tasks are waiting for a response from an external process or system, like for instance, a database server that takes time to a execute a query.

This package takes advantage of the ReactPHP library asynchronous programming features to implement an efficient custom HTTP server totally written in PHP.

The package allows developers to create Web applications just by creating handler functions or controller classes that process the requests for specific URLs and return the responses.

This way, PHP developers can write pure PHP Web applications without needing to use external Web server applications.

Manuel Lemos
Picture of Ahmad Mustapha
Name: Ahmad Mustapha <contact>
Classes: 24 packages by
Country: Nigeria Nigeria
Age: ???
All time rank: 226511 in Nigeria Nigeria
Week rank: 178 Up7 in Nigeria Nigeria Up
Innovation award
Innovation award
Nominee: 9x

Example

<?php

use App\Server;
use
Psr\Log\NullLogger;
use
React\Cache\ArrayCache;
use
React\EventLoop\Factory;
use
React\Http\Server as ReactHttpServer;
use
React\Socket\Server as ReactSocketServer;
use
WyriHaximus\React\Http\Middleware\WebrootPreloadMiddleware;

require
'vendor/autoload.php';

define('ROOT_DIR', __DIR__ . '/');
define('CONTROLLER_NAMESPACE', 'App\\Controller\\');

$loop = Factory::create();

$socket = new ReactSocketServer(8080, $loop);
$server = new ReactHttpServer(
   
$loop,
    new
WebrootPreloadMiddleware('public', new NullLogger(), new ArrayCache()),
    new
Server(),
);

$server->on('error', function (Throwable $exception){
    echo(
$exception);
});

$server->listen($socket);

echo
"Server running at http://127.0.0.1:8080\n";

$loop->run();


Details

_Simple ReactPHP Http Server_

A simple http server written with pure PHP and with the help of ReactPHP.

<ol> <li><a href="#Installation">Installation</a></li> </ol>

Installation

Make sure that you have composer installed

Clone repository

gti clone https://github.com/Ahmard/reactphp-simple-http-server

Navigate to the directory

cd reactphp-simple-http-server

Install composer dependencies

composer install

Start server

php server.php

Visit http://localhost:8181 and see.


  Files folder image Files (24)  
File Role Description
Files folder imageapp (2 files, 2 directories)
Files folder imagepublic (2 directories)
Files folder imageview (2 files, 2 directories)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file nodemon.json Data Auxiliary data
Accessible without login Plain text file phpstan.neon Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation
Accessible without login Plain text file routes.php Conf. Routes script
Accessible without login Plain text file server.php Example Example script

  Files folder image Files (24)  /  app  
File Role Description
Files folder imageController (1 file, 1 directory)
Files folder imageCore (1 file)
  Plain text file Response.php Class Class source
  Plain text file Server.php Class Class source

  Files folder image Files (24)  /  app  /  Controller  
File Role Description
Files folder imageFunc (1 file)
  Plain text file MainController.php Class Class source

  Files folder image Files (24)  /  app  /  Controller  /  Func  
File Role Description
  Plain text file FormController.php Class Class source

  Files folder image Files (24)  /  app  /  Core  
File Role Description
  Plain text file View.php Class Class source

  Files folder image Files (24)  /  public  
File Role Description
Files folder imagecss (2 files)
Files folder imagejs (2 files)

  Files folder image Files (24)  /  public  /  css  
File Role Description
  Accessible without login Plain text file bootstrap-icons.css Data Auxiliary data
  Accessible without login Plain text file bootstrap.min.css Data Auxiliary data

  Files folder image Files (24)  /  public  /  js  
File Role Description
  Accessible without login Plain text file bootstrap.bundle.min.js Data Auxiliary data
  Accessible without login Plain text file jquery-3.5.1.min.js Data Auxiliary data

  Files folder image Files (24)  /  view  
File Role Description
Files folder imagefunc (1 directory)
Files folder imageincludes (2 files)
  Accessible without login Plain text file index.php Aux. Auxiliary script
  Accessible without login Plain text file list.php Aux. Auxiliary script

  Files folder image Files (24)  /  view  /  func  
File Role Description
Files folder imageform (4 files)

  Files folder image Files (24)  /  view  /  func  /  form  
File Role Description
  Accessible without login Plain text file file.php Aux. Auxiliary script
  Accessible without login Plain text file index.php Aux. Auxiliary script
  Accessible without login Plain text file submitted.php Aux. Auxiliary script
  Accessible without login Plain text file uploaded.php Example Example script

  Files folder image Files (24)  /  view  /  includes  
File Role Description
  Accessible without login Plain text file footer.php Aux. Auxiliary script
  Accessible without login Plain text file header.php Aux. Auxiliary script

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:115
This week:0
All time:9,571
This week:47Up