PHPackages                             henacodes/pexpress - 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. [Framework](/categories/framework)
4. /
5. henacodes/pexpress

ActiveLibrary[Framework](/categories/framework)

henacodes/pexpress
==================

A php implementation of express js

42PHP

Since Apr 13Pushed 2y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Pexpress PHP Library
====================

[](#pexpress-php-library)

Pexpress is a lightweight PHP library for building RESTful APIs with ease. It provides a simple and intuitive interface for defining routes and handling HTTP requests. This README will guide you through the process of installing and using the Pexpress library effectively.

Table of Contents
-----------------

[](#table-of-contents)

- Installation
- Usage
    - Initializing the App
    - Defining Routes
    - Listening to Requests
- Examples
- Contributing
- License

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

[](#installation)

To use Pexpress in your PHP project, you need to follow these steps:

1. Update your `composer.json` file to include the library as a dependency:

```
   "require": {
   "henacodes/pexpress": "dev-master"
   }
```

2. Run the following command to install the library and its dependencies:

    composer install

Usage
-----

[](#usage)

### Initializing the App

[](#initializing-the-app)

To get started with Pexpress, you need to initialize the App class. This class will be responsible for handling incoming requests and routing them to the appropriate handlers.

In your PHP file (index.php or any other file), include the autoload file generated by Composer:

```
require_once 'vendor/autoload.php';
```

Next, import the App namespace:

```
use Henacodes\Pexpress\App;
```

Now, you can initialize the App class:

```
$app = new App();
```

### Defining Routes

[](#defining-routes)

Pexpress allows you to define routes using different HTTP methods such as GET, POST, PUT, and PATCH. To define a route, you need to call the corresponding method on the $app instance and provide a callback function that will handle the request.

Here's an example of defining a GET route:

```
$app->get("/users/:id", function ($req, $res, $next) {
$res->json(["message" => "Hello"]);
});
```

You can define routes for other HTTP methods in a similar manner (post, put, patch).

### Listening to Requests

[](#listening-to-requests)

After defining your routes, you need to start listening for incoming requests. To do this, simply call the listen method on the $app instance:

$app-&gt;listen();

This will start the server and listen for incoming requests on the specified port (usually port 8000).

### MIddlewares

[](#middlewares)

You can add as many middlewares as possible. Here is an example

```
$middleware_one = function($request, $response, $next){
    if (your_logic_here){
        // if its true , preceed to the next miiddleware
        $next()
    } else {
        // abort the process and response with an error response
        res.status(400)
        res.json({ error:"Bad request" })
    }
}

$middleware_two = function($request, $response, $next){
    // your second middleware
}

$app->get("/posts", $middleware_one, $middleware_two)
```

Examples
--------

[](#examples)

For more examples and usage details, please refer to the examples directory in this repository.

Contributing
------------

[](#contributing)

Contributions are welcome! If you have any improvements or new features to add, please create a pull request.

License
-------

[](#license)

This project is licensed under the MIT License.

###  Health Score

14

—

LowBetter than 2% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity19

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/613b4e9ebaa069a788f864b2c243f08af09a4a18db2cff9dcc9b389cf88c0aee?d=identicon)[henacodes](/maintainers/henacodes)

---

Top Contributors

[![henacodes](https://avatars.githubusercontent.com/u/117871961?v=4)](https://github.com/henacodes "henacodes (15 commits)")

### Embed Badge

![Health badge](/badges/henacodes-pexpress/health.svg)

```
[![Health](https://phpackages.com/badges/henacodes-pexpress/health.svg)](https://phpackages.com/packages/henacodes-pexpress)
```

###  Alternatives

[laravel/passport

Laravel Passport provides OAuth2 server support to Laravel.

3.4k85.0M532](/packages/laravel-passport)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M259](/packages/laravel-dusk)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

712181.8M596](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M121](/packages/cakephp-chronos)[laravel/pail

Easily delve into your Laravel application's log files directly from the command line.

91545.3M590](/packages/laravel-pail)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
