lightsuner / stack-codeigniter
This is a wrapper for codeigniter to use it in conjunction with stackphp.com
Installs: 1 299
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ~5.3
- symfony/http-foundation: ~2.1
- symfony/http-kernel: ~2.1
This package is not auto-updated.
Last update: 2024-11-09 16:02:47 UTC
README
##About This is a wrapper for Codeigniter. It implements HttpKernelInterface that allows you to use Codeigniter with other frameworks using StackPHP.
This implementation has got much dirty code. I would be glad if you help clean it.
##Install
Add stack-codeigniter in your composer.json:
{ "require": { "lightsuner/stack-codeigniter": "dev-develop" } }
Now tell composer to download the component by running the command:
$ php composer.phar update lightsuner/stack-codeigniter
Composer will install the component to your project's vendor/lightsuner
directory.
##Usage
Replace index.php with this:
use StackCI\Application as CIApplication; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Session\Session; require_once __DIR__.'/vendor/autoload.php'; $session = new Session(); $session->start(); $request = Request::createFromGlobals(); $request->setSession($session); $ciApp = (new CIApplication(__DIR__, 'development'))->init(); $app = (new Stack\Builder()) ->resolve($ciApp); $response = $app->handle($request); $response->send(); $app->terminate($request, $response);
You can also execute some code before Codeigniter will initialized. Use StackCI\Application::beforeKernelLoad()
:
$ciApp = (new \StackCI\Application(__DIR__, 'development')) ->beforeKernelLoad(function(){ //... some code goes here define('PUBPATH', FCPATH."public"); if( ! ini_get('date.timezone')) { date_default_timezone_set('GMT'); } //... some other code }) ->init();
Use with WanWizard's datamapper:
To make it work correctly you should add STACKCIEXTPATH
to third_party/datamapper/bootstrap.php
.... if ( ! function_exists('load_class')) { function &load_class($class, $directory = 'libraries', $prefix = 'CI_') ...... foreach (array(STACKCIEXTPATH, BASEPATH, APPPATH) as $path) { if (file_exists($path.$directory.'/'.$class.'.php')) { $name = $prefix.$class; if (class_exists($name) === FALSE) { require($path.$directory.'/'.$class.'.php'); } break; } } .....
and then load datamapper's bootstrap
$ciApp = (new CIApplication(__DIR__, 'development')) ->beforeKernelLoad(function(){ //load Datamapper's bootstrap require_once APPPATH.'third_party/datamapper/bootstrap.php'; }) ->init();
##Details
There is a BaseApplication
and two folders - Ext
and Orig
.
BaseApplication
do the same thing than default Codeigniters's index.php - load and run Kernel.Orig
contains original files of Codeigniter such as Router, Input, Output, Loader and etc.Ext
contains extended files
####New functional:
Libraries/Session
- new method migrate
:
$this->session->migrate($destroy, $lifetime);
Core/Input
- new method getRequest
:
$this->input->getRequest();
##Advices
- Use LazyHttpKernel to use
stack-codeigniter
in conjunction with other frameworks throughstackPHP
.