PHPackages                             edgaralexanderfr/php-espresso - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. edgaralexanderfr/php-espresso

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

edgaralexanderfr/php-espresso
=============================

Runtime web server for PHP.

v1.0.0(3y ago)113MITPHP

Since Mar 12Pushed 1y ago1 watchersCompare

[ Source](https://github.com/edgaralexanderfr/php-espresso)[ Packagist](https://packagist.org/packages/edgaralexanderfr/php-espresso)[ RSS](/packages/edgaralexanderfr-php-espresso/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (4)Used By (0)

PHP Espresso Framework
======================

[](#php-espresso-framework)

 [![PHP Espresso Example GIF](https://raw.githubusercontent.com/edgaralexanderfr/php-espresso/master/public/img/example.gif)](https://raw.githubusercontent.com/edgaralexanderfr/php-espresso/master/public/img/example.gif)

 [ ![View last release](https://camo.githubusercontent.com/5f91738d53903aba2069561fbdceb02771bd586cbe278e7682d39780db40c949/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f76657273696f6e2d76312e302e302d696e666f726d6174696f6e616c2e737667 "View last release") ](https://github.com/edgaralexanderfr/php-espresso/releases/latest) [ ![PHP 8.0.0](https://camo.githubusercontent.com/f97204f03da3d8db85c4245557ef560485257d523964bdebbeded83591feef6c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d3e3d382e302e302d696e666f726d6174696f6e616c2e737667 "Requires PHP 8.0.0 or major") ](https://www.php.net/releases/8.0/es.php) [![Experimental](https://camo.githubusercontent.com/e146268f65d989491fa670d2d703ee505eb95510e5b6c0d4dbed9100fb1bec7f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6578706572696d656e74616c2d637269746963616c2e737667 "Not intended for production use")](https://camo.githubusercontent.com/e146268f65d989491fa670d2d703ee505eb95510e5b6c0d4dbed9100fb1bec7f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6578706572696d656e74616c2d637269746963616c2e737667) [![Sockets](https://camo.githubusercontent.com/686265d81f19ead3876e7ca90b8856ff2d8339b5f8e928341218a2e51730bf47/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f736f636b6574732d79656c6c6f77677265656e2e737667 "PHP sockets module")](https://camo.githubusercontent.com/686265d81f19ead3876e7ca90b8856ff2d8339b5f8e928341218a2e51730bf47/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f736f636b6574732d79656c6c6f77677265656e2e737667) [ ![Composer](https://camo.githubusercontent.com/12e95c11196bf13b4559e3de270c94190bd1715d7e6f4dc1e8bf484fd3f29941/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f6d706f7365722d79656c6c6f77677265656e2e737667 "composer require edgaralexanderfr/php-espresso") ](https://packagist.org/packages/edgaralexanderfr/php-espresso)

**PHP Espresso** is a small PHP Framework I created to develop runtime web servers for PHP running CLI programs and scripts. Very similar to frameworks like **Express** for ***NodeJS***, **Gorilla Mux** for ***Golang***, etc.

**IMPORTANT NOTE:** This is just a *proof of concept* to test the reliability of a runtime web server for PHP, its use and implementation is discouraged for **production-level** projects as it's an experimental framework for learning purposes.

PHP was designed to be a **Single-Threaded** **Non-Asynchronous** programming language, hence, the implementation of these type of web servers is very difficult as there will be always blocking processes for each request, hence, this server/framework is non-scalable.

##### Table of contents 📖

[](#table-of-contents-)

1. [Requirements](#requirements)
2. [Installation](#installation)
3. [Usage](#usage)

- [3.1 Creating a basic web server](#server)
- [3.2 Serving a basic static HTML Page](#html)
- [3.3 Create a POST request](#post)
- [3.4 Complete Rest API CRUD example](#crud)
- [3.5 Defining middlewares](#middlewares)
- [3.6 Asynchronous programming](#async)

Requirements
------------

[](#requirements)

1. **PHP 8.0.0 or major**
2. **Have PHP sockets module installed and enabled**
3. **Composer**
4. **Have a initted Composer project**

Installation
------------

[](#installation)

Install **PHP Espresso** via Composer:

```
composer require edgaralexanderfr/php-espresso
```

Usage
-----

[](#usage)

### Creating a basic web server

[](#creating-a-basic-web-server)

Create a ***server.php*** file inside your project with the following program:

```
