GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - lightsuner/StackCI: StackPHP implementation for CodeIgniter 2

BranchesTags
Open more actions menu

Latest commit

 

History

17 Commits
17 Commits

Folders and files

NameName
Last commit message
Last commit date
src
src
 
 
.gitignore
.gitignore
 
 
composer.json
composer.json
 
 
readme.md
readme.md
 
 

Repository files navigation

Codeigniter stackPHP(HttpKernelInterface) Implementation

Latest Stable Version Total Downloads

StackPHP

##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.

  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:

    $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 through stackPHP.

About

StackPHP implementation for CodeIgniter 2

Resources

Readme
Activity

Stars

3 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.