mabslabs / mabs
Mabs 微型框架
v2.1.1
2024-09-22 20:55 UTC
Requires
- php: >=7.2.5
- symfony/http-foundation: ~5.4
Requires (Dev)
- phpunit/phpunit: ^9.5
This package is not auto-updated.
Last update: 2024-09-22 20:57:00 UTC
README
Mabs 是一个快速、轻量且易于学习的 PHP 微型框架。
特性
- 容器
- 事件分发器
- 路由
- HttpFoundation (Symfony2 组件)
- 扩展 PHP 库的简便方法
入门
安装
您可以使用 Composer 安装 Mabs 框架(推荐)。
$ composer require mabslabs/mabs
快速入门
// web/index.php <?php require_once __DIR__.'/../vendor/autoload.php'; $app = new Mabs\Application(); $app->get('hello/(name)', function ($name) { return 'Hello '.$name; })->run();
更多详情
// web/index.php <?php require_once __DIR__.'/../vendor/autoload.php'; use \Symfony\Component\HttpFoundation\RedirectResponse; $app = new Mabs\Application(); $container = $app->getContainer(); $app->get('/', function () use ($container) { $url = $container['router']->generateUrl('hello_page', array('name' => 'World')); return new RedirectResponse($url); }); $app->get('hello/(name)', function ($name) { return 'Hello '.$name; }, 'hello_page'); $app->run();
许可
此包可在 MIT 许可证 下使用。