承接 rougin/spark-plug 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

rougin/spark-plug

最新稳定版本:v0.6.3

Composer 安装命令:

composer require rougin/spark-plug

包简介

Codeigniter 3 in a single variable.

README 文档

README

Latest Version on Packagist Software License Build Status Coverage Status Total Downloads

A special package that returns an application based on Codeigniter 3 as a single variable. Might be useful when testing a Codeigniter 3 project to frameworks such as PHPUnit.

Installation

Install Spark Plug through Composer:

$ composer require rougin/spark-plug

Basic Usage

Using the Instance helper

$ci = Rougin\SparkPlug\Instance::create();

// You can now use the CI_Controller instance
$ci->load->helper('inflector');

Note

Instead of CI_Controller, it returns Rougin\SparkPlug\Controller for type-hinting its helpers and libraries.

Using the SparkPlug class

use Rougin\SparkPlug\SparkPlug;

$sparkplug = new SparkPlug($GLOBALS, $_SERVER);

$ci = $sparkplug->instance();

// The Inflector helper is now loaded ---
$ci->load->helper('inflector');
// --------------------------------------

Modify constants to be defined

use Rougin\SparkPlug\SparkPlug;

$sparkplug = new SparkPlug($GLOBALS, $_SERVER);

// Set the value of the APPPATH constant ---
$sparkplug->set('APPPATH', '/path/to/app');
// -----------------------------------------

$ci = $sparkplug->instance();

Available constants that can be modified:

  • APPPATH
  • VENDOR
  • VIEWPATH

Note

If setting a new APPPATH value, the value of VIEWPATH will be set to APPPATH/views.

Mock CI_Controller for unit testing

use Rougin\SparkPlug\Instance;

class SampleTest extends \PHPUnit_Framework_TestCase
{
    public function testCodeigniterInstance()
    {
        // Directory path to the test application
        $application = __DIR__ . '/TestApp';

        // Instance::create($path, $_SERVER, $GLOBALS)
        $ci = Instance::create($application);

        $this->assertInstanceOf('CI_Controller', $ci);
    }
}

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Credits

License

The MIT License (MIT). Please see LICENSE for more information.

统计信息

  • 总下载量: 17.91k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 16
  • 点击次数: 0
  • 依赖项目数: 4
  • 推荐数: 6

GitHub 信息

  • Stars: 16
  • Watchers: 1
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-06-13