genesis/micro-framework
Composer 安装命令:
composer require genesis/micro-framework
包简介
Simple classes tied with a convention.
README 文档
README
Bunch of classes with a bit of convention to get your started.
Setup
To get boiler plate code for a quick start, run the following commands (bash/cli acquainted users):
composer require genesis/micro-framework make -f vendor/genesis/micro-framework/Makefile build
At the end of the output you'll receive a snippet for the composer.json file, add and now start local server:
make serve
open localhost:8000 in your browser and you should see hello world!.
If the above steps do not work, run make -f vendor/genesis/micro-framework/Makefile cleanup and proceed step by step:
Place the following code in your index file. Assuming that:
- the index file is in the public folder.
- you have an autoloading rule in composer.json file that points the namespace App\Controller to your controllers folder.
<?php use Genesis\Microframework\Service\Config; use Genesis\Microframework\Service\Router; use Genesis\Microframework\Service\Request; use App\Controller; require __DIR__ . '/../vendor/autoload.php'; $router = new Router($_GET, $_SERVER); $router->registerRoutes( [ '/' => Controller\Index::class, ] ); Config::set('view_path', __DIR__ . '/../src/View/'); $router->dispatchRequest(new Request());
The dispatcher will call upon the index() method in each controller only.
Database
To add database support, add config for database like so in the above file before the dispatchRequest() call:
Config::set('db_params', [ 'dbengine' => 'mysql', 'host' => 'localhost', 'port' => 3306, 'dbname' => 'myDB', 'username' => 'root', 'password' => 'password' ]);
And call upon the getMapperService() method to persist your models. For more information follow guide here https://github.com/forceedge01/genesis-persistence.
View
Call a view in your controller like so:
# src/Controller/Index <?php namespace App\Controller; use Genesis\MicroFramework\Controller\BaseController; /** * Index class. */ class Index extends BaseController { public function index() { echo $this->render('index.php', [ 'name' => 'Abdul' ]); } }
Expect to have a view file src/View/index.php which renders the variable name. There is no engine supplied but can be added.
genesis/micro-framework 适用场景与选型建议
genesis/micro-framework 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 08 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 genesis/micro-framework 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 genesis/micro-framework 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-08-15