yidemir / mikro
面向传统的微服务方法
1.6.0
2022-05-30 09:56 UTC
Requires
- php: ^8.1
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- ext-openssl: *
- ext-pdo: *
- ext-readline: *
Requires (Dev)
- phpstan/phpstan: ^1.2
- phpunit/phpunit: ^9.0
- 1.x-dev
- 1.6.0
- 1.5.0
- 1.4.7
- 1.4.3
- 1.4.0
- 1.3.0
- 1.1.10
- 1.1.5
- 1.1.4
- 1.1.2
- 1.1.0
- 1.0.1
- 1.0.0
- 0.x-dev
- 0.6.10
- 0.6.0
- 0.5.95
- 0.5.9
- 0.5.8
- 0.5.7
- 0.5.6
- v0.5.5
- 0.5.4
- 0.5.3
- 0.5.2
- 0.5.1
- 0.5.0
- 0.3.8
- 0.3.0
- 0.2.16
- 0.2.14
- 0.2.12
- 0.2.10
- 0.2.8
- 0.2.6
- 0.2.4
- 0.2.2
- 0.2.0
- 0.0.6
- 0.0.4
- 0.0.2
- dev-big-update
- dev-view-template-component
- dev-table-component
This package is auto-updated.
Last update: 2024-09-29 04:49:04 UTC
README
项目处于开发中。 请勿使用(尚未)
mikro - 面向传统的微服务方法
该项目是一个工具,旨在通过简单的方法解决一些任务和请求,而不是一个框架。
我试图将这个项目更进一步,这是一个我作为爱好开始的。与之前的版本相比,已经发生了根本性的变化。
可用包
- 缓存 - 这是一个简单的缓存结构。
- 配置 - 这是一个具有设置器和获取器的简单配置结构。
- 控制台 - 根据命令行参数执行回调。
- 容器 - 一个简单的服务容器。
- 加密 - 使用 OpenSSL 对字符串进行加密和解密。
- 数据库 - 使用 PDO 实例简化您的 CRUD 操作。
- 事件 - 一个简单的事件监听器和发射器。
- 辅助工具 - 字符串和数组辅助工具等
- JWT - 一个简单的 JSON Web Token 身份验证结构。
- 本地化 - 多语言/本地化结构
- 日志记录器 - 基本日志记录
- 请求 - 一个方便的方式访问 PHP 全局请求变量。
- 响应 - 向客户端发送数据/响应。
- 路由器 - 一个具有分组和中间件支持的超级简单路由器。
- 验证器 - 一个简单的数据验证库。
- 视图 - 支持块和模板的视图渲染器。
安装
您可以通过 composer 安装此包。
composer require yidemir/mikro
使用
路由
Router\get('/', fn() => Response\view('home'));
Router\group('/admin', fn() => [ Router\get('/', 'DashboardController::index'), Router\resource('/posts', PostController::class), Router\get('/service/status', fn() => Response\json(['status' => true], 200) ], ['AdminMiddleware::handle']); Router\files('/', __DIR__ . '/sync-directory');
Router\error(fn() => Response\html('Default 404 error', 404));
数据库
$products = DB\query('select * from products order by id desc')->fetchAll(); $product = DB\query('select * from products where id=?', [$id])->fetch(); DB\insert('products', ['name' => $name, 'description' => $description]); $id = DB\last_insert_id(); DB\update('products', ['name' => $newName], 'where id=?', [$id]); DB\delete('products', 'where id=?', [$id]);
视图和模板
@View\set('title', 'Page title!');
@View\start('content');
<p>Secure print: @=$message; or unsecure print @echo $message;</p>
@View\stop();
@View\start('scripts');
<script src="app.js"></script>
@View\push();
@echo View\render('layout');
<!-- layout.php --> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>@View\get('title', 'Hey!');</title> </head> <body> @View\get('content'); @View\get('scripts'); </body> </html>
所有方法和常量在源代码中有文档说明。一般文档将很快发布。
测试
composer test
变更日志
有关最近更改的更多信息,请参阅变更日志。
贡献
有关详细信息,请参阅贡献。
安全
如果您发现任何安全相关的问题,请通过电子邮件demiriy@gmail.com联系,而不是使用问题跟踪器。
鸣谢
许可证
MIT 许可证(MIT)。有关更多信息,请参阅许可证文件。