nercury/code-igniter-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nercury/code-igniter-bundle

Composer 安装命令:

composer require nercury/code-igniter-bundle

包简介

Allows loading Code Igniter as a bundle and eases migration to Symfony.

README 文档

README

What it is

Integrates CodeIgniter as a bundle in Symfony2.

Usage

Install bundle over composer, and load it in AppKernel:

$bundles = array(
    ...
    new Nercury\CodeIgniterBundle\NercuryCodeIgniterBundle(),
    ...
);

In case you are still using Symfony 2.0, do not forget to autoload the bundle in autoload.php:

'Nercury' => __DIR__.'/../vendor/nercury/code-igniter-bundle',

In config.yml, specify paths to CodeIgniter directories:

nercury_code_igniter:
    application_path: %kernel.root_dir%/../CodeIgniter_210/application
    system_path: %kernel.root_dir%/../CodeIgniter_210/system

Bundle uses a bit of code from CodeIgniter 2.1.0, so it should work the best with 2.1.0 version. Bundle automatically tries to detect code igniter controllers based on current URL. To disable this add the following line to config.yml:

nercury_code_igniter:
    ...
    detect_controllers: false

To get CI response in any symfony controller, use:

$response = $this->get("ci")->getResponse($request);

This method will redirect request handling to CodeIgniter and it's routing.

The need might arise just to use some legacy CodeIgniter code to get libraries, modules or even helpers. In that case, you can get CI instance:

$CI = & $this->get("ci")->getInstance();

In case "getResponse" was called before, it will return the controller used. Otherwise, a fake controller instance will be created. Therefore "getResponse" can not be used if "getInstance" was called.

Symfony2 container is available to CodeIgniter like a library. For example, to get a doctrine service in CI controller, call:

$this->symfony->get('doctrine');

To use Symfony2 database configuration in CodeIgniter, do this in database.php config file

$connection = $GLOBALS['CI_symfony']->get('doctrine')->getConnection(); // :)

$db['default']['hostname'] = $connection->getHost();
$db['default']['username'] = $connection->getUsername();
$db['default']['password'] = $connection->getPassword();
$db['default']['database'] = $connection->getDatabase();

That's it for now.

Contributions are welcome.

统计信息

  • 总下载量: 736
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 5
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2012-02-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固