# Dumbo A lightweight, friendly PHP framework for HTTP — inspired by Hono. [Join us on Discord](https://discord.gg/nAq2h9BfsU) ![Dumbo](/dumbo.jpeg) ## Install ```bash composer require notrab/dumbo ``` ## Quickstart Here's a basic example of how it works! ```php get("/", function ($context) { return $context->json(["message" => "Hello, Dumbo!"]); }); $app->run(); ``` See the [examples](/examples) directory for more quickstarts. ## Routing ```php get('/users', function($context) { /* ... */ }); $app->post('/users', function($context) { /* ... */ }); $app->put('/users/:id', function($context) { /* ... */ }); $app->delete('/users/:id', function($context) { /* ... */ }); ``` ### Params ```php get('/users/:id', function($context) { $id = $context->req->param('id'); return $context->json(['id' => $id]); }); ``` ### Nested ```php get('/nested', function($context) { return $context->text('This is a nested route'); }); $app->route('/prefix', $nestedApp); ``` ## Context ```php get('/', function($context) { $pathname = $context->req->pathname(); $routePath = $context->req->routePath(); $queryParam = $context->req->query('param'); $tags = $context->req->queries('tags'); $body = $context->req->body(); $userAgent = $context->req->header('User-Agent'); }); ``` ### Response ```php json(['key' => 'value']); return $context->text('Hello, World!'); return $context->html('

Hello, World!

'); return $context->redirect('/new-url'); ``` ### Middleware ```php use(function($context, $next) { $response = $next($context); return $response; }); ``` ### Custom context ```php set('DB_URL', 'mysql://user:pass@localhost/mydb'); $app->set('API_KEY', 'your-secret-key'); $app->set('DEBUG', true); // Get configuration values $dbUrl = $app->get('DB_URL'); $apiKey = $app->get('API_KEY'); $debug = $app->get('DEBUG'); // Use configuration in your routes $app->get('/api/data', function(Context $context) { $apiKey = $context->get('API_KEY'); // Use $apiKey in your logic... return $context->json(['message' => 'API key is set']); }); $app->run(); ```