https://github.com/krakphp/mw-codeigniter
CodeIgniter Integration with the Mw Http Framework
https://github.com/krakphp/mw-codeigniter
Last synced: about 1 year ago
JSON representation
CodeIgniter Integration with the Mw Http Framework
- Host: GitHub
- URL: https://github.com/krakphp/mw-codeigniter
- Owner: krakphp
- Created: 2016-12-05T08:29:12.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-12-05T08:35:27.000Z (over 9 years ago)
- Last Synced: 2025-01-29T06:52:19.515Z (over 1 year ago)
- Language: PHP
- Size: 5.86 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
Awesome Lists containing this project
README
Mw Http CodeIgniter Integration
===============================
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.
1. Create a controller to handle the Mw Routes named like `application/controllers/mw.php`
2. Create your mw app inside of the controller method.
.. code-block:: php
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();
}
}
3. Register the default route to point to your mw/index action. All undefined routes will lead to it now.
.. code-block:: php
load->view`` method in the CI framework.
CodeIgniter\\CodeIgniterServiceProvider
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The service provider defines the following services:
codeigniter.server
This is a `Krak\Mw\Http\Server` 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.