2024-08-14 20:37:48 +01:00
2024-07-17 09:34:05 +01:00
2024-07-17 13:31:12 +01:00
2024-07-17 13:50:06 +01:00
2024-07-15 18:59:04 +01:00
2024-07-17 09:34:05 +01:00
2024-08-14 20:37:48 +01:00
2024-08-14 20:37:48 +01:00
2024-07-15 13:29:07 +00:00

Dumbo

A lightweight, friendly PHP framework for HTTP — inspired by Hono.

Dumbo

Install

composer require notrab/dumbo

Quickstart

Here's a basic example of how it works!

<?php

use Dumbo\Dumbo;

$app = new Dumbo();

$app->get("/", function ($c) {
    return $c->json('Hello Dumbo!');
});

$app->run();

Routing

<?php

$app->get('/users', function($c) { /* ... */ });
$app->post('/users', function($c) { /* ... */ });
$app->put('/users/:id', function($c) { /* ... */ });
$app->delete('/users/:id', function($c) { /* ... */ });

Params

<?php

$app->get('/users/:id', function($c) {
    $id = $c->req->param('id');

    return $c->json(['id' => $id]);
});

Nested

<?php

$nestedApp = new Dumbo();

$nestedApp->get('/nested', function($c) {
    return $c->text('This is a nested route');
});

$app->route('/prefix', $nestedApp);

Context

<?php

$app->get('/', function($c) {
    $pathname = $c->req->pathname();
    $routePath = $c->req->routePath();
    $queryParam = $c->req->query('param');
    $tags = $c->req->queries('tags');
    $body = $c->req->body();
    $userAgent = $c->req->header('User-Agent');
});

Response

<?php

return $c->json(['key' => 'value']);
return $c->text('Hello, World!');
return $c->html('<h1>Hello, World!</h1>');
return $c->redirect('/new-url');

Middleware

<?php

$app->use(function($c, $next) {
    $response = $next($c);

    return $response;
});
Description
A lightweight, friendly PHP framework for HTTP.
Readme MIT 788 KiB
Languages
PHP 100%