krak/mw-codeigniter
Composer 安装命令:
composer require krak/mw-codeigniter
包简介
Mw CodeIgniter Integration
README 文档
README
You can integrate the Mw Http framework with CI by embedding an Mw app inside of the CI framework.
The idea for this integration came from a legacy site I've managed before where we couldn't remove the old CI framework, but we needed to add new features that the Mw Http Framework could solve. So, this allows a nice bridge from an older system to a new one.
Installation
Install with composer at krak/mw-codeigniter
Usage
To have an app that you want to embed inside of the CI framework, you'll need to do a few things.
- Create a controller to handle the Mw Routes named like application/controllers/mw.php
- Create your mw app inside of the controller method.
<?php use Krak\Mw\Http; class Mw extends CI_Controller { public function index() { $app = new Http\App(); $app->with(Http\Package\std()); $app->with(Http\Package\codeIgniter($this)); $app->get('/a', function() { return '/a'; }); $app->get('/b', function() { return '/b'; }); $app->get('/exception', function() { throw new \InvalidArgumentException('Whoa!!!!'); }); $app->serve(); } }
- Register the default route to point to your mw/index action. All undefined routes will lead to it now.
<?php $route['404_override'] = 'mw';
Make sure to add the CodeIgniter package last or at least later on in the packages.
API
These are all relative to the Krak\Mw\Http\Package namespace.
codeIgniter($ci, array $config = [])
returns a configured instance of CodeIgniter\CodeIgniterPackage. $ci must be an instance of the Codeigniter controller. $config is an array that allows the following configuration options:
- show_stack_trace
- Forwarded to ciExceptionHandler
CodeIgniter\ciExceptionHandler($show_stack_trace = true)
An exception handler that will use the CI show_error global func to display the exception. $show_stack_trace determines whether or not to display the stack trace of the exception along with the exception message.
CodeIgniter\ciNotFoundHandler()
Simply uses the show_404 method from the CI framework to display a page not found.
CodeIgniter\ciViewMarshalResponse($ci)
Allows actions to return two-tuples of [string, array] which represent the view path and the data to load into the view. This internally uses the $this->load->view method in the CI framework.
CodeIgniter\CodeIgniterServiceProvider
The service provider defines the following services:
- codeigniter.server
- This is a KrakMwHttpServer which serves from inside of the CI framework.
- server
- Replaces the server parameter with the codeigniter.server instance.
Required Parameters
- codeigniter.ci
- An isntance of CI. This value is automatically filled if you are using the CodeIgniterPackage interface; however, it will need to be set if you are using the service provider on its own.
krak/mw-codeigniter 适用场景与选型建议
krak/mw-codeigniter 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 700 次下载、GitHub Stars 达 1, 最近一次更新时间为 2016 年 07 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 krak/mw-codeigniter 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 krak/mw-codeigniter 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 700
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-07-21