riverside/php-express
riverside/php-express has 35 GitHub stars and 13 forks. GitHot measured 0 stars in 24 hours and 0 in 7 days. Last checked 2026-11-09 13:48 UTC. Last push 2026-04-24.
:horse: PHP micro-framework inspired by Express.js
Measured star growth
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- Collecting history
- in 1 month
- Collecting history
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
Originalphp-express
PHP micro-framework inspired by Express.js
| Build | GitHub pages | Stable | License |
|---|---|---|---|
Requirements
- PHP >= 7.1
- PHP extensions:
- JSON (
ext-json)
- JSON (
Installation
If Composer is not installed on your system yet, you may go ahead and install it using this command line:
$ curl -sS https://getcomposer.org/installer | php
Next, add the following require entry to the composer.json file in the root of your project.
{
"require" : {
"riverside/php-express" : "^2.0.1"
}
}
Finally, use Composer to install php-express and its dependencies:
$ php composer.phar install
Routing
<?php
$app = new \Riverside\Express\Application();
$app->get('/', function ($req, $res) {
$res->send('hello world');
});
Route methods
<?php
// GET method route
$app->get('/', function ($req, $res) {
$res->send('GET request to the homepage');
});
// POST method route
$app->post('/', function ($req, $res) {
$res->send('POST request to the homepage');
});
Route paths
<?php
$app->get('/', function ($req, $res) {
$res->send('root');
});
$app->get('about', function ($req, $res) {
$res->send('about');
});
$app->get('random.text', function ($req, $res) {
$res->send('random.text');
});
Response methods
| Method | Description |
|---|---|
| $res->end() | End the response process. |
| $res->json() | Send a JSON response. |
| $res->redirect() | Redirect a request. |
| $res->render() | Render a view template. |
| $res->send() | Send a response of various types. |
| $res->sendStatus() | Set the response status code and send its string representation as the response body. |
$app->route()
<?php
$app->route('/book')
->get(function ($req, $res) {
$res->send('Get a random book');
})
->post(function ($req, $res) {
$res->send('Add a book');
})
->put(function ($req, $res) {
$res->send('Update the book');
});
Router
<?php
$router = new \Riverside\Express\Router($app);
$router->param('uuid', '[a-f\d]{8}-[a-f\d]{4}-[a-f\d]{4}-[a-f\d]{4}-[a-f\d]{12}');
$router->get('/', function ($req, $res) {
$res->send('Birds home page');
});
$router->get('about', function ($req, $res) {
$res->send('About birds');
});
$router->get('ticket/:uuid/', function($req, $res) {
echo $req->params['uuid'];
});
$router->run();
Middleware
$app->use(function($req, $res) {
$res->header('X-Frame-Options', 'DENY');
$res->header('X-Powered-By', false);
});
$app->use('/cors', function($req, $res) {
$res->header('Access-Control-Allow-Origin', '*');
});
Explore related projects
freeCodeCamp/freeCodeCamp
freeCodeCamp.org's open-source codebase and curriculum. Learn math, programming, and computer science for free.
458,819 starsdonnemartin/system-design-primer
Learn how to design large-scale systems. Prep for the system design interview. Includes Anki flashcards.
377,437 starsreact/react
The library for web and native user interfaces.
252,444 starsvuejs/vue
This is the repo for Vue 2. For Vue 3, go to https://github.com/vuejs/core
212,624 stars