定制 kenjis/codeigniter-cli 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

kenjis/codeigniter-cli

Composer 安装命令:

composer require kenjis/codeigniter-cli

包简介

A command-line tool for CodeIgniter 3.0

README 文档

README

Latest Stable Version Total Downloads Latest Unstable Version License

Scrutinizer Code Quality Coverage Status Build Status

This package provides a Cli tool for CodeIgniter 3.0.

This includes a few commands and you can create your commands easily.

This is based on Aura.Cli_Project 2.0.

Included Commands

generate migration ... Generates migration file skeleton.
migrate            ... Run migrations.
migrate status     ... List all migration files and versions.
seed               ... Seed the database.
run                ... Run controller.

Folder Structure

codeigniter/
├── application/
├── ci_instance.php ... script to generate CodeIgniter instance
├── cli             ... command file
├── config/         ... config folder
└── vendor/

Requirements

  • PHP 5.4.0 or later
  • composer command
  • Git

Installation

Install this project with Composer:

$ cd /path/to/codeigniter/
$ composer require kenjis/codeigniter-cli --dev

Install command file (cli) and config files (config/) to your CodeIgniter project:

$ php vendor/kenjis/codeigniter-cli/install.php
  • Above command always overwrites exisiting files.
  • You must run it at CodeIgniter project root folder.

Fix the paths in ci_instance.php if you need.

$system_path        = 'vendor/codeigniter/framework/system';
$application_folder = 'application';
$doc_root           = 'public'; // where index.php is

If you install CodeIgniter using codeigniter-composer-installer, you don't have to change them.

Usage

Show command list.

$ cd /path/to/codeigniter/
$ php cli

Show help for a command.

$ php cli help seed

Create Database Seeds

Seeder class must be placed in application/database/seeds folder.

application/database/seeds/ProductSeeder.php

<?php

class ProductSeeder extends Seeder {

	public function run()
	{
		$this->db->truncate('product');

		$data = [
			'category_id' => 1,
			'name' => 'CodeIgniter Book',
			'detail' => 'Very good CodeIgniter book.',
			'price' => 3800,
		];
		$this->db->insert('product', $data);

		$data = [
			'category_id' => 2,
			'name' => 'CodeIgniter CD',
			'detail' => 'Great CodeIgniter CD.',
			'price' => 4800,
		];
		$this->db->insert('product', $data);

		$data = [
			'category_id' => 3,
			'name' => 'CodeIgniter DVD',
			'detail' => 'Awesome CodeIgniter DVD.',
			'price' => 5800,
		];
		$this->db->insert('product', $data);
	}

}

Create User Command

Command class name must be *Command.php and be placed in application/commands folder.

application/commands/TestCommand.php

<?php

class TestCommand extends Command {

	public function __invoke()
	{
		$this->stdio->outln('<<green>>This is TestCommand class<<reset>>');
	}

}

Command Help class name must be *CommandHelp.php and be placed in application/commands folder.

application/commands/TestCommandHelp.php

<?php

class TestCommandHelp extends Help {

	public function init()
	{
		$this->setSummary('A single-line summary.');
		$this->setUsage('<arg1> <arg2>');
		$this->setOptions(array(
			'f,foo' => "The -f/--foo option description",
			'bar::' => "The --bar option description",
		));
		$this->setDescr("A multi-line description of the command.");
	}

}

Reference

How to Run Tests

To run tests, you must install CodeIgniter first.

$ composer create-project kenjis/codeigniter-composer-installer codeigniter
$ cd codeigniter
$ composer require kenjis/codeigniter-cli:1.0.x@dev --dev
$ php vendor/kenjis/codeigniter-cli/install.php
$ cd vendor/kenjis/codeigniter-cli
$ composer install
$ phpunit

Related Projects for CodeIgniter 3.0

kenjis/codeigniter-cli 适用场景与选型建议

kenjis/codeigniter-cli 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 37.69k 次下载、GitHub Stars 达 94, 最近一次更新时间为 2015 年 04 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「cli」 「command」 「command line」 「codeigniter」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 kenjis/codeigniter-cli 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 kenjis/codeigniter-cli 我们能提供哪些服务?
定制开发 / 二次开发

基于 kenjis/codeigniter-cli 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 37.69k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 100
  • 点击次数: 9
  • 依赖项目数: 0
  • 推荐数: 2

GitHub 信息

  • Stars: 94
  • Watchers: 9
  • Forks: 22
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-04-28