notrab/dumbo
Composer 安装命令:
composer require notrab/dumbo
包简介
A lightweight, friendly PHP framework for HTTP.
关键字:
README 文档
README
Dumbo
A lightweight, friendly PHP framework for HTTP — Inspired by Hono.
Features
- 🚀 Lightweight and fast
- 🧩 Middleware support
- 🛣️ Flexible routing with parameters
- 🔒 Built-in security features (CSRF, JWT)
- 🍪 Cookie management
- 📅 Date helpers
- 🔍 Request ID for tracing
- 📁 Static file serving
- 🔐 Basic and Bearer authentication
- 📝 Logging support
- 🗃️ HTTP caching
- 🔄 CORS support
- 🧬 Environment-based configuration
Install
composer require notrab/dumbo
Quickstart
Here's a basic example of how it works!
<?php require __DIR__ . '/vendor/autoload.php'; use Dumbo\Dumbo; $app = new Dumbo(); $app->use(function ($context, $next) { $context->set('message', 'Hello from middleware!'); return $next($context); }); $app->get('/', function ($context) { return $context->json([ 'message' => $context->get('message'), 'timestamp' => time() ]); }); $app->get('/users/:id', function ($context) { $id = $context->req->param('id'); return $context->json(['userId' => $id]); }); $app->post('/users', function ($context) { $body = $context->req->body(); return $context->json($body, 201); }); $app->run();
See the examples directory for more quickstarts.
License
Dumbo is open-sourced software licensed under the MIT license.
Contributors
Documentation
Routing
<?php $app->get('/users', function($context) { /* ... */ }); $app->post('/users', function($context) { /* ... */ }); $app->put('/users/:id', function($context) { /* ... */ }); $app->delete('/users/:id', function($context) { /* ... */ });
Params
<?php $app->get('/users/:id', function($context) { $id = $context->req->param('id'); return $context->json(['id' => $id]); });
Nested
<?php $nestedApp = new Dumbo(); $nestedApp->get('/nested', function($context) { return $context->text('This is a nested route'); }); $app->route('/prefix', $nestedApp);
Context
<?php $app->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 return $context->json(['key' => 'value']); return $context->text('Hello, World!'); return $context->html('<h1>Hello, World!</h1>'); return $context->redirect('/new-url');
Middleware
<?php $app->use(function($context, $next) { $response = $next($context); return $response; });
Custom context
<?php $app = new Dumbo(); // Set configuration values $app->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();
notrab/dumbo 适用场景与选型建议
notrab/dumbo 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 367 次下载、GitHub Stars 达 305, 最近一次更新时间为 2024 年 07 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「framework」 「http」 「router」 「hono」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 notrab/dumbo 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 notrab/dumbo 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 notrab/dumbo 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP Framework HLEB2 is the foundation of the web application. Provides ease of development and application performance.
repository php library
Router
PMVC App Action Router
Database alias router extension for Nette Framework
http客户端
统计信息
- 总下载量: 367
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 306
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-07-15
