2017 © Pedro Peláez
 

library stack-codeigniter

This is a wrapper for codeigniter to use it in conjunction with stackphp.com

image

lightsuner/stack-codeigniter

This is a wrapper for codeigniter to use it in conjunction with stackphp.com

  • Monday, June 16, 2014
  • by lightsuner
  • Repository
  • 1 Watchers
  • 4 Stars
  • 1,251 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Codeigniter stackPHP(HttpKernelInterface) Implementation

Latest Stable Version Total Downloads, (*1)

StackPHP, (*2)

About

This is a wrapper for Codeigniter. It implements HttpKernelInterface that allows you to use Codeigniter with other frameworks using StackPHP., (*3)

This implementation has got much dirty code. I would be glad if you help clean it., (*4)

Install

Add stack-codeigniter in your composer.json: ```json { "require": { "lightsuner/stack-codeigniter": "dev-develop" } }, (*5)

Now tell composer to download the component by running the command:

``` bash
$ php composer.phar update lightsuner/stack-codeigniter

Composer will install the component to your project's vendor/lightsuner directory., (*6)

Usage

Replace index.php with this:, (*7)

```php use StackCI\Application as CIApplication; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Session\Session;, (*8)

require_once DIR.'/vendor/autoload.php';, (*9)

$session = new Session(); $session->start();, (*10)

$request = Request::createFromGlobals(); $request->setSession($session);, (*11)

$ciApp = (new CIApplication(DIR, 'development'))->init();, (*12)

$app = (new Stack\Builder()) ->resolve($ciApp);, (*13)

$response = $app->handle($request);, (*14)

$response->send();, (*15)

$app->terminate($request, $response);, (*16)


You can also execute some code before Codeigniter will initialized. Use ``StackCI\Application::beforeKernelLoad()``: ```php $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:, (*17)

To make it work correctly you should add STACKCIEXTPATH to third_party/datamapper/bootstrap.php ```php .... if ( ! function_exists('load_class')) { function &load_class($class, $directory = 'libraries', $prefix = 'CI_'), (*18)

......

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
```php
$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., (*19)

  1. BaseApplication do the same thing than default Codeigniters's index.php - load and run Kernel.
  2. Orig contains original files of Codeigniter such as Router, Input, Output, Loader and etc.
  3. Ext contains extended files

New functional:

Libraries/Session - new method migrate:, (*20)

```php $this->session->migrate($destroy, $lifetime);, (*21)


``Core/Input`` - new method ``getRequest``: ```php $this->input->getRequest();

Advices

  • Use LazyHttpKernel to use stack-codeigniter in conjunction with other frameworks through stackPHP.

The Versions

16/06 2014

dev-develop

dev-develop

This is a wrapper for codeigniter to use it in conjunction with stackphp.com

  Sources   Download

The Requires

 

by Avatar lightsuner

codeigniter stackphp httpkernelinterface