An open API service indexing awesome lists of open source software.

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

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.