├── .coveralls.yml ├── .gitignore ├── .scrutinizer.yml ├── .travis.yml ├── LICENSE.md ├── README.md ├── ci_instance.php ├── cli ├── composer.json ├── composer.lock ├── config ├── Common.php ├── Dev.php ├── Prod.php ├── Test.php └── _env.php ├── install.php ├── phpunit.php ├── phpunit.xml.dist ├── src ├── .placeholder ├── Command │ ├── Command.php │ ├── Generate.php │ ├── Generate │ │ ├── Migration.php │ │ └── templates │ │ │ └── Migration.txt │ ├── GenerateHelp.php │ ├── Migrate.php │ ├── MigrateHelp.php │ ├── Run.php │ ├── RunHelp.php │ ├── Seed.php │ └── SeedHelp.php └── UserConfig.php ├── tests ├── CliTest.php ├── Command │ ├── CommandTest.php │ ├── GenerateHelpTest.php │ ├── GenerateTest.php │ ├── MigrateHelpTest.php │ ├── MigrateTest.php │ ├── RunHelpTest.php │ ├── RunTest.php │ ├── SeedHelpTest.php │ └── SeedTest.php ├── Fake │ ├── Command │ │ └── Test.php │ ├── migrations │ │ ├── 001_Create_bbs.php │ │ ├── 002_Create_captcha.php │ │ ├── 20150429090001_Create_bbs.php │ │ ├── 20150429100002_Create_captcha.php │ │ ├── 20150429110003_Create_category.php │ │ └── 20150429120004_Create_product.php │ ├── seeds │ │ ├── Table1Seeder.php │ │ ├── Table2Seeder.php │ │ └── Table3Seeder.php │ ├── user_commands │ │ ├── TestCommand.php │ │ └── TestCommandHelp.php │ └── user_commands_bad │ │ └── BadCommand.php ├── UserConfigTest.php └── data │ └── sqlite-database.db └── tmp └── .placeholder /.coveralls.yml: -------------------------------------------------------------------------------- 1 | src_dir: . 2 | coverage_clover: build/logs/clover.xml 3 | json_path: build/logs/coveralls-upload.json 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /tmp/* 2 | !/tmp/.placeholder 3 | /vendor 4 | /nbproject/ 5 | build/ 6 | -------------------------------------------------------------------------------- /.scrutinizer.yml: -------------------------------------------------------------------------------- 1 | filter: 2 | excluded_paths: 3 | - tests/* 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | 3 | php: 4 | - 5.4 5 | - 5.5 6 | - 5.6 7 | 8 | before_script: 9 | - pwd 10 | - export cwd=`pwd` 11 | - composer self-update 12 | - cd .. 13 | - pwd 14 | - composer create-project kenjis/codeigniter-composer-installer codeigniter 15 | - cd codeigniter 16 | - composer require kenjis/codeigniter-cli:1.0.x@dev --dev 17 | - mv vendor/kenjis/codeigniter-cli vendor/kenjis/codeigniter-cli.tmp 18 | - mv "$cwd" vendor/kenjis/codeigniter-cli 19 | - php vendor/kenjis/codeigniter-cli/install.php 20 | - cd vendor/kenjis/codeigniter-cli 21 | - pwd 22 | - composer install 23 | 24 | script: 25 | - pwd 26 | - phpunit --coverage-text 27 | 28 | after_script: 29 | - pwd 30 | - php vendor/bin/coveralls -v 31 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2015 Kenji Suzuki 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Cli for CodeIgniter 3.0 2 | 3 | [![Latest Stable Version](https://poser.pugx.org/kenjis/codeigniter-cli/v/stable)](https://packagist.org/packages/kenjis/codeigniter-cli) [![Total Downloads](https://poser.pugx.org/kenjis/codeigniter-cli/downloads)](https://packagist.org/packages/kenjis/codeigniter-cli) [![Latest Unstable Version](https://poser.pugx.org/kenjis/codeigniter-cli/v/unstable)](https://packagist.org/packages/kenjis/codeigniter-cli) [![License](https://poser.pugx.org/kenjis/codeigniter-cli/license)](https://packagist.org/packages/kenjis/codeigniter-cli) 4 | 5 | [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/kenjis/codeigniter-cli/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/kenjis/codeigniter-cli/?branch=master) 6 | [![Coverage Status](https://coveralls.io/repos/kenjis/codeigniter-cli/badge.svg?branch=master)](https://coveralls.io/r/kenjis/codeigniter-cli?branch=master) 7 | [![Build Status](https://travis-ci.org/kenjis/codeigniter-cli.svg?branch=master)](https://travis-ci.org/kenjis/codeigniter-cli) 8 | 9 | This package provides a Cli tool for [CodeIgniter](https://github.com/bcit-ci/CodeIgniter) 3.0. 10 | 11 | This includes a few commands and you can create your commands easily. 12 | 13 | This is based on Aura.Cli_Project 2.0. 14 | 15 | ## Included Commands 16 | 17 | ~~~ 18 | generate migration ... Generates migration file skeleton. 19 | migrate ... Run migrations. 20 | migrate status ... List all migration files and versions. 21 | seed ... Seed the database. 22 | run ... Run controller. 23 | ~~~ 24 | 25 | ## Folder Structure 26 | 27 | ``` 28 | codeigniter/ 29 | ├── application/ 30 | ├── ci_instance.php ... script to generate CodeIgniter instance 31 | ├── cli ... command file 32 | ├── config/ ... config folder 33 | └── vendor/ 34 | ``` 35 | 36 | ## Requirements 37 | 38 | * PHP 5.4.0 or later 39 | * `composer` command 40 | * Git 41 | 42 | ## Installation 43 | 44 | Install this project with Composer: 45 | 46 | ~~~ 47 | $ cd /path/to/codeigniter/ 48 | $ composer require kenjis/codeigniter-cli --dev 49 | ~~~ 50 | 51 | Install command file (`cli`) and config files (`config/`) to your CodeIgniter project: 52 | 53 | ~~~ 54 | $ php vendor/kenjis/codeigniter-cli/install.php 55 | ~~~ 56 | 57 | * Above command always overwrites exisiting files. 58 | * You must run it at CodeIgniter project root folder. 59 | 60 | Fix the paths in `ci_instance.php` if you need. 61 | 62 | ~~~php 63 | $system_path = 'vendor/codeigniter/framework/system'; 64 | $application_folder = 'application'; 65 | $doc_root = 'public'; // where index.php is 66 | ~~~ 67 | 68 | If you install CodeIgniter using [codeigniter-composer-installer](https://github.com/kenjis/codeigniter-composer-installer), you don't have to change them. 69 | 70 | ## Usage 71 | 72 | Show command list. 73 | 74 | ~~~ 75 | $ cd /path/to/codeigniter/ 76 | $ php cli 77 | ~~~ 78 | 79 | Show help for a command. 80 | 81 | ~~~ 82 | $ php cli help seed 83 | ~~~ 84 | 85 | ## Create Database Seeds 86 | 87 | Seeder class must be placed in `application/database/seeds` folder. 88 | 89 | `application/database/seeds/ProductSeeder.php` 90 | ~~~php 91 | db->truncate('product'); 98 | 99 | $data = [ 100 | 'category_id' => 1, 101 | 'name' => 'CodeIgniter Book', 102 | 'detail' => 'Very good CodeIgniter book.', 103 | 'price' => 3800, 104 | ]; 105 | $this->db->insert('product', $data); 106 | 107 | $data = [ 108 | 'category_id' => 2, 109 | 'name' => 'CodeIgniter CD', 110 | 'detail' => 'Great CodeIgniter CD.', 111 | 'price' => 4800, 112 | ]; 113 | $this->db->insert('product', $data); 114 | 115 | $data = [ 116 | 'category_id' => 3, 117 | 'name' => 'CodeIgniter DVD', 118 | 'detail' => 'Awesome CodeIgniter DVD.', 119 | 'price' => 5800, 120 | ]; 121 | $this->db->insert('product', $data); 122 | } 123 | 124 | } 125 | ~~~ 126 | 127 | ## Create User Command 128 | 129 | Command class name must be `*Command.php` and be placed in `application/commands` folder. 130 | 131 | `application/commands/TestCommand.php` 132 | ~~~php 133 | stdio->outln('<>This is TestCommand class<>'); 140 | } 141 | 142 | } 143 | ~~~ 144 | 145 | Command Help class name must be `*CommandHelp.php` and be placed in `application/commands` folder. 146 | 147 | `application/commands/TestCommandHelp.php` 148 | ~~~php 149 | setSummary('A single-line summary.'); 156 | $this->setUsage(' '); 157 | $this->setOptions(array( 158 | 'f,foo' => "The -f/--foo option description", 159 | 'bar::' => "The --bar option description", 160 | )); 161 | $this->setDescr("A multi-line description of the command."); 162 | } 163 | 164 | } 165 | ~~~ 166 | 167 | ### Reference 168 | 169 | * https://github.com/auraphp/Aura.Cli_Project 170 | * http://auraphp.com/framework/2.x/en/cli/ 171 | 172 | ## How to Run Tests 173 | 174 | To run tests, you must install CodeIgniter first. 175 | 176 | ~~~ 177 | $ composer create-project kenjis/codeigniter-composer-installer codeigniter 178 | $ cd codeigniter 179 | $ composer require kenjis/codeigniter-cli:1.0.x@dev --dev 180 | $ php vendor/kenjis/codeigniter-cli/install.php 181 | $ cd vendor/kenjis/codeigniter-cli 182 | $ composer install 183 | $ phpunit 184 | ~~~ 185 | 186 | ## Related Projects for CodeIgniter 3.0 187 | 188 | * [CodeIgniter Composer Installer](https://github.com/kenjis/codeigniter-composer-installer) 189 | * [CI PHPUnit Test](https://github.com/kenjis/ci-phpunit-test) 190 | * [CodeIgniter Simple and Secure Twig](https://github.com/kenjis/codeigniter-ss-twig) 191 | * [CodeIgniter Doctrine](https://github.com/kenjis/codeigniter-doctrine) 192 | * [CodeIgniter Deployer](https://github.com/kenjis/codeigniter-deployer) 193 | * [CodeIgniter3 Filename Checker](https://github.com/kenjis/codeigniter3-filename-checker) 194 | -------------------------------------------------------------------------------- /ci_instance.php: -------------------------------------------------------------------------------- 1 | 6 | * @license MIT License 7 | * @copyright 2015 Kenji Suzuki 8 | * @link https://github.com/kenjis/codeigniter-cli 9 | * 10 | * Based on http://codeinphp.github.io/post/codeigniter-tip-accessing-codeigniter-instance-outside/ 11 | * Thanks! 12 | */ 13 | 14 | $cwd = getcwd(); 15 | chdir(__DIR__); 16 | 17 | define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development'); 18 | 19 | $system_path = 'vendor/codeigniter/framework/system'; 20 | $application_folder = 'application'; 21 | $doc_root = 'public'; 22 | 23 | if (realpath($system_path) !== false) { 24 | $system_path = realpath($system_path) . '/'; 25 | } 26 | $system_path = rtrim($system_path, '/') . '/'; 27 | 28 | define('BASEPATH', str_replace("\\", "/", $system_path)); 29 | define('FCPATH', $doc_root . '/'); 30 | define('APPPATH', $application_folder . '/'); 31 | define('VIEWPATH', $application_folder . '/views/'); 32 | 33 | require(BASEPATH . 'core/Common.php'); 34 | 35 | if (file_exists(APPPATH . 'config/' . ENVIRONMENT . '/constants.php')) { 36 | require(APPPATH . 'config/' . ENVIRONMENT . '/constants.php'); 37 | } else { 38 | require(APPPATH . 'config/constants.php'); 39 | } 40 | 41 | $charset = strtoupper(config_item('charset')); 42 | ini_set('default_charset', $charset); 43 | 44 | if (extension_loaded('mbstring')) { 45 | define('MB_ENABLED', TRUE); 46 | // mbstring.internal_encoding is deprecated starting with PHP 5.6 47 | // and it's usage triggers E_DEPRECATED messages. 48 | @ini_set('mbstring.internal_encoding', $charset); 49 | // This is required for mb_convert_encoding() to strip invalid characters. 50 | // That's utilized by CI_Utf8, but it's also done for consistency with iconv. 51 | mb_substitute_character('none'); 52 | } else { 53 | define('MB_ENABLED', FALSE); 54 | } 55 | 56 | // There's an ICONV_IMPL constant, but the PHP manual says that using 57 | // iconv's predefined constants is "strongly discouraged". 58 | if (extension_loaded('iconv')) { 59 | define('ICONV_ENABLED', TRUE); 60 | // iconv.internal_encoding is deprecated starting with PHP 5.6 61 | // and it's usage triggers E_DEPRECATED messages. 62 | @ini_set('iconv.internal_encoding', $charset); 63 | } else { 64 | define('ICONV_ENABLED', FALSE); 65 | } 66 | 67 | $GLOBALS['CFG'] = & load_class('Config', 'core'); 68 | $GLOBALS['UNI'] = & load_class('Utf8', 'core'); 69 | $GLOBALS['SEC'] = & load_class('Security', 'core'); 70 | 71 | load_class('Loader', 'core'); 72 | load_class('Router', 'core'); 73 | load_class('Input', 'core'); 74 | load_class('Lang', 'core'); 75 | 76 | require(BASEPATH . 'core/Controller.php'); 77 | 78 | function &get_instance() 79 | { 80 | return CI_Controller::get_instance(); 81 | } 82 | 83 | chdir($cwd); 84 | 85 | return new CI_Controller(); 86 | -------------------------------------------------------------------------------- /cli: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | 7 | * @license MIT License 8 | * @copyright 2015 Kenji Suzuki 9 | * @link https://github.com/kenjis/codeigniter-cli 10 | */ 11 | 12 | $path = __DIR__; 13 | chdir($path); 14 | 15 | /** @const ROOTPATH CodeIgniter project root directory */ 16 | define('ROOTPATH', __DIR__ . '/'); 17 | 18 | require "{$path}/vendor/autoload.php"; 19 | 20 | // generate CodeIgniter instance 21 | $ci = require "{$path}/ci_instance.php"; 22 | 23 | class_alias('Kenjis\CodeIgniter_Cli\Command\Command', 'Command'); 24 | class_alias('Kenjis\CodeIgniter_Cli\Command\Seed', 'Seeder'); 25 | class_alias('Aura\Cli\Help', 'Help'); 26 | 27 | $kernel = (new \Aura\Project_Kernel\Factory)->newKernel( 28 | $path, 29 | 'Aura\Cli_Kernel\CliKernel' 30 | ); 31 | $status = $kernel(); 32 | exit($status); 33 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "kenjis/codeigniter-cli", 3 | "description": "A command-line tool for CodeIgniter 3.0", 4 | "keywords": [ 5 | "cli", 6 | "command", 7 | "command line", 8 | "codeigniter" 9 | ], 10 | "license": "MIT", 11 | "authors": [ 12 | { 13 | "name": "Kenji Suzuki", 14 | "homepage": "https://github.com/kenjis" 15 | } 16 | ], 17 | "require": { 18 | "php": ">=5.4.0", 19 | "aura/cli-kernel": "~2.0", 20 | "monolog/monolog": "~1.0" 21 | }, 22 | "autoload": { 23 | "psr-4": { 24 | "Kenjis\\CodeIgniter_Cli\\": "src/", 25 | "Kenjis\\CodeIgniter_Cli\\_Config\\": "config/" 26 | } 27 | }, 28 | "extra": { 29 | "aura": { 30 | "type": "project", 31 | "config": { 32 | "common": "Kenjis\\CodeIgniter_Cli\\_Config\\Common", 33 | "dev": "Kenjis\\CodeIgniter_Cli\\_Config\\Dev", 34 | "test": "Kenjis\\CodeIgniter_Cli\\_Config\\Test", 35 | "prod": "Kenjis\\CodeIgniter_Cli\\_Config\\Prod" 36 | } 37 | }, 38 | "branch-alias": { 39 | "dev-master": "1.0.x-dev" 40 | } 41 | }, 42 | "require-dev": { 43 | "satooshi/php-coveralls": "0.6.*" 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", 5 | "This file is @generated automatically" 6 | ], 7 | "hash": "e45b08519d8e808d9baf5947da94447e", 8 | "packages": [ 9 | { 10 | "name": "aura/cli", 11 | "version": "2.1.1", 12 | "source": { 13 | "type": "git", 14 | "url": "https://github.com/auraphp/Aura.Cli.git", 15 | "reference": "b550cd79beff793ec5feeea248ccd4ba537c8603" 16 | }, 17 | "dist": { 18 | "type": "zip", 19 | "url": "https://api.github.com/repos/auraphp/Aura.Cli/zipball/b550cd79beff793ec5feeea248ccd4ba537c8603", 20 | "reference": "b550cd79beff793ec5feeea248ccd4ba537c8603", 21 | "shasum": "" 22 | }, 23 | "require": { 24 | "php": ">=5.3.0" 25 | }, 26 | "require-dev": { 27 | "aura/di": "~2.0" 28 | }, 29 | "type": "library", 30 | "extra": { 31 | "aura": { 32 | "type": "library", 33 | "config": { 34 | "common": "Aura\\Cli\\_Config\\Common" 35 | } 36 | }, 37 | "branch-alias": { 38 | "dev-develop-2": "2.0.x-dev" 39 | } 40 | }, 41 | "autoload": { 42 | "psr-4": { 43 | "Aura\\Cli\\": "src/", 44 | "Aura\\Cli\\_Config\\": "config/" 45 | } 46 | }, 47 | "notification-url": "https://packagist.org/downloads/", 48 | "license": [ 49 | "BSD-2-Clause" 50 | ], 51 | "authors": [ 52 | { 53 | "name": "Aura.Cli Contributors", 54 | "homepage": "https://github.com/auraphp/Aura.Cli/contributors" 55 | } 56 | ], 57 | "description": "Provides the equivalent of request (Context) and response (Stdio) classes for a command line environment, including Getopt support.", 58 | "homepage": "https://github.com/auraphp/Aura.Cli", 59 | "keywords": [ 60 | "cli", 61 | "command", 62 | "command line", 63 | "getopt", 64 | "options", 65 | "stdio" 66 | ], 67 | "time": "2015-03-27 17:23:08" 68 | }, 69 | { 70 | "name": "aura/cli-kernel", 71 | "version": "2.0.3", 72 | "source": { 73 | "type": "git", 74 | "url": "https://github.com/auraphp/Aura.Cli_Kernel.git", 75 | "reference": "708e0dce510adb9e18e36800afbb9d777528136e" 76 | }, 77 | "dist": { 78 | "type": "zip", 79 | "url": "https://api.github.com/repos/auraphp/Aura.Cli_Kernel/zipball/708e0dce510adb9e18e36800afbb9d777528136e", 80 | "reference": "708e0dce510adb9e18e36800afbb9d777528136e", 81 | "shasum": "" 82 | }, 83 | "require": { 84 | "aura/cli": "~2.0", 85 | "aura/dispatcher": "~2.0", 86 | "aura/project-kernel": "~2.0", 87 | "php": ">=5.4.0" 88 | }, 89 | "type": "library", 90 | "extra": { 91 | "aura": { 92 | "type": "kernel", 93 | "config": { 94 | "common": "Aura\\Cli_Kernel\\_Config\\Common", 95 | "cli-kernel-test": "Aura\\Cli_Kernel\\_Config\\CliKernelTest" 96 | } 97 | }, 98 | "branch-alias": { 99 | "dev-develop-2": "2.0.x-dev" 100 | } 101 | }, 102 | "autoload": { 103 | "psr-4": { 104 | "Aura\\Cli_Kernel\\": "src/", 105 | "Aura\\Cli_Kernel\\_Config\\": "config/" 106 | } 107 | }, 108 | "notification-url": "https://packagist.org/downloads/", 109 | "license": [ 110 | "BSD-2-Clause" 111 | ], 112 | "authors": [ 113 | { 114 | "name": "Aura.Cli_Kernel Contributors", 115 | "homepage": "https://github.com/auraphp/Aura.Cli_Kernel/contributors" 116 | } 117 | ], 118 | "description": "The kernel files for an Aura CLI project.", 119 | "homepage": "https://github.com/auraphp/Aura.Cli_Kernel", 120 | "keywords": [ 121 | "cli", 122 | "kernel" 123 | ], 124 | "time": "2015-03-28 16:12:39" 125 | }, 126 | { 127 | "name": "aura/di", 128 | "version": "2.2.3", 129 | "source": { 130 | "type": "git", 131 | "url": "https://github.com/auraphp/Aura.Di.git", 132 | "reference": "c0d51c15e105c4b6df90d4c29d9e4dac6bee4d5b" 133 | }, 134 | "dist": { 135 | "type": "zip", 136 | "url": "https://api.github.com/repos/auraphp/Aura.Di/zipball/c0d51c15e105c4b6df90d4c29d9e4dac6bee4d5b", 137 | "reference": "c0d51c15e105c4b6df90d4c29d9e4dac6bee4d5b", 138 | "shasum": "" 139 | }, 140 | "require": { 141 | "php": ">=5.3.0" 142 | }, 143 | "type": "library", 144 | "extra": { 145 | "aura": { 146 | "type": "library" 147 | } 148 | }, 149 | "autoload": { 150 | "psr-4": { 151 | "Aura\\Di\\": "src/" 152 | } 153 | }, 154 | "notification-url": "https://packagist.org/downloads/", 155 | "license": [ 156 | "BSD-2-Clause" 157 | ], 158 | "authors": [ 159 | { 160 | "name": "Aura.Di Contributors", 161 | "homepage": "https://github.com/auraphp/Aura.Di/contributors" 162 | } 163 | ], 164 | "description": "Provides a dependency injection container system with native support for constructor- and setter-based injection, lazy-loading of services, and inheritable configuration of setters and constructor params.", 165 | "homepage": "https://github.com/auraphp/Aura.Di", 166 | "keywords": [ 167 | "container", 168 | "dependency injection", 169 | "dependency injection container", 170 | "di", 171 | "di container" 172 | ], 173 | "time": "2015-05-31 20:45:07" 174 | }, 175 | { 176 | "name": "aura/dispatcher", 177 | "version": "2.0.3", 178 | "source": { 179 | "type": "git", 180 | "url": "https://github.com/auraphp/Aura.Dispatcher.git", 181 | "reference": "cd28755a86f7a016a97022d2078e15e743c2a48d" 182 | }, 183 | "dist": { 184 | "type": "zip", 185 | "url": "https://api.github.com/repos/auraphp/Aura.Dispatcher/zipball/cd28755a86f7a016a97022d2078e15e743c2a48d", 186 | "reference": "cd28755a86f7a016a97022d2078e15e743c2a48d", 187 | "shasum": "" 188 | }, 189 | "require": { 190 | "php": ">=5.4.0" 191 | }, 192 | "type": "library", 193 | "extra": { 194 | "aura": { 195 | "type": "library" 196 | }, 197 | "branch-alias": { 198 | "dev-develop-2": "2.0.x-dev" 199 | } 200 | }, 201 | "autoload": { 202 | "psr-4": { 203 | "Aura\\Dispatcher\\": "src/" 204 | } 205 | }, 206 | "notification-url": "https://packagist.org/downloads/", 207 | "license": [ 208 | "BSD-2-Clause" 209 | ], 210 | "authors": [ 211 | { 212 | "name": "Aura.Dispatcher Contributors", 213 | "homepage": "https://github.com/auraphp/Aura.Dispatcher/contributors" 214 | } 215 | ], 216 | "description": "Creates objects from a factory and invokes methods using named parameters; also provides a trait for invoking closures and object methods with named parameters.", 217 | "homepage": "https://github.com/auraphp/Aura.Dispatcher", 218 | "keywords": [ 219 | "controller", 220 | "dispatcher", 221 | "factory" 222 | ], 223 | "time": "2015-03-27 19:36:51" 224 | }, 225 | { 226 | "name": "aura/project-kernel", 227 | "version": "2.1.1", 228 | "source": { 229 | "type": "git", 230 | "url": "https://github.com/auraphp/Aura.Project_Kernel.git", 231 | "reference": "644475dbb4859c24aeeb309fd76a9c3e644ba9be" 232 | }, 233 | "dist": { 234 | "type": "zip", 235 | "url": "https://api.github.com/repos/auraphp/Aura.Project_Kernel/zipball/644475dbb4859c24aeeb309fd76a9c3e644ba9be", 236 | "reference": "644475dbb4859c24aeeb309fd76a9c3e644ba9be", 237 | "shasum": "" 238 | }, 239 | "require": { 240 | "aura/di": "~2.0", 241 | "php": ">=5.3.0", 242 | "psr/log": "~1.0" 243 | }, 244 | "type": "library", 245 | "extra": { 246 | "aura": { 247 | "type": "kernel", 248 | "config": { 249 | "common": "Aura\\Project_Kernel\\_Config\\Common" 250 | } 251 | }, 252 | "branch-alias": { 253 | "dev-develop-2": "2.0.x-dev" 254 | } 255 | }, 256 | "autoload": { 257 | "psr-4": { 258 | "Aura\\Project_Kernel\\": "src/", 259 | "Aura\\Project_Kernel\\_Config\\": "config/" 260 | } 261 | }, 262 | "notification-url": "https://packagist.org/downloads/", 263 | "license": [ 264 | "BSD-2-Clause" 265 | ], 266 | "authors": [ 267 | { 268 | "name": "Aura.Project_Kernel Contributors", 269 | "homepage": "https://github.com/auraphp/Aura.Project_Kernel/contributors" 270 | } 271 | ], 272 | "description": "The shared kernel files for an Aura project.", 273 | "homepage": "https://github.com/auraphp/Aura.Project_Kernel", 274 | "keywords": [ 275 | "kernel", 276 | "project" 277 | ], 278 | "time": "2015-03-27 22:29:48" 279 | }, 280 | { 281 | "name": "monolog/monolog", 282 | "version": "1.14.0", 283 | "source": { 284 | "type": "git", 285 | "url": "https://github.com/Seldaek/monolog.git", 286 | "reference": "b287fbbe1ca27847064beff2bad7fb6920bf08cc" 287 | }, 288 | "dist": { 289 | "type": "zip", 290 | "url": "https://api.github.com/repos/Seldaek/monolog/zipball/b287fbbe1ca27847064beff2bad7fb6920bf08cc", 291 | "reference": "b287fbbe1ca27847064beff2bad7fb6920bf08cc", 292 | "shasum": "" 293 | }, 294 | "require": { 295 | "php": ">=5.3.0", 296 | "psr/log": "~1.0" 297 | }, 298 | "provide": { 299 | "psr/log-implementation": "1.0.0" 300 | }, 301 | "require-dev": { 302 | "aws/aws-sdk-php": "^2.4.9", 303 | "doctrine/couchdb": "~1.0@dev", 304 | "graylog2/gelf-php": "~1.0", 305 | "php-console/php-console": "^3.1.3", 306 | "phpunit/phpunit": "~4.5", 307 | "phpunit/phpunit-mock-objects": "2.3.0", 308 | "raven/raven": "~0.8", 309 | "ruflin/elastica": ">=0.90 <3.0", 310 | "swiftmailer/swiftmailer": "~5.3", 311 | "videlalvaro/php-amqplib": "~2.4" 312 | }, 313 | "suggest": { 314 | "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB", 315 | "doctrine/couchdb": "Allow sending log messages to a CouchDB server", 316 | "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)", 317 | "ext-mongo": "Allow sending log messages to a MongoDB server", 318 | "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server", 319 | "php-console/php-console": "Allow sending log messages to Google Chrome", 320 | "raven/raven": "Allow sending log messages to a Sentry server", 321 | "rollbar/rollbar": "Allow sending log messages to Rollbar", 322 | "ruflin/elastica": "Allow sending log messages to an Elastic Search server", 323 | "videlalvaro/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib" 324 | }, 325 | "type": "library", 326 | "extra": { 327 | "branch-alias": { 328 | "dev-master": "1.14.x-dev" 329 | } 330 | }, 331 | "autoload": { 332 | "psr-4": { 333 | "Monolog\\": "src/Monolog" 334 | } 335 | }, 336 | "notification-url": "https://packagist.org/downloads/", 337 | "license": [ 338 | "MIT" 339 | ], 340 | "authors": [ 341 | { 342 | "name": "Jordi Boggiano", 343 | "email": "j.boggiano@seld.be", 344 | "homepage": "http://seld.be" 345 | } 346 | ], 347 | "description": "Sends your logs to files, sockets, inboxes, databases and various web services", 348 | "homepage": "http://github.com/Seldaek/monolog", 349 | "keywords": [ 350 | "log", 351 | "logging", 352 | "psr-3" 353 | ], 354 | "time": "2015-06-19 13:29:54" 355 | }, 356 | { 357 | "name": "psr/log", 358 | "version": "1.0.0", 359 | "source": { 360 | "type": "git", 361 | "url": "https://github.com/php-fig/log.git", 362 | "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b" 363 | }, 364 | "dist": { 365 | "type": "zip", 366 | "url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b", 367 | "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b", 368 | "shasum": "" 369 | }, 370 | "type": "library", 371 | "autoload": { 372 | "psr-0": { 373 | "Psr\\Log\\": "" 374 | } 375 | }, 376 | "notification-url": "https://packagist.org/downloads/", 377 | "license": [ 378 | "MIT" 379 | ], 380 | "authors": [ 381 | { 382 | "name": "PHP-FIG", 383 | "homepage": "http://www.php-fig.org/" 384 | } 385 | ], 386 | "description": "Common interface for logging libraries", 387 | "keywords": [ 388 | "log", 389 | "psr", 390 | "psr-3" 391 | ], 392 | "time": "2012-12-21 11:40:51" 393 | } 394 | ], 395 | "packages-dev": [ 396 | { 397 | "name": "guzzle/guzzle", 398 | "version": "v3.9.3", 399 | "source": { 400 | "type": "git", 401 | "url": "https://github.com/guzzle/guzzle3.git", 402 | "reference": "0645b70d953bc1c067bbc8d5bc53194706b628d9" 403 | }, 404 | "dist": { 405 | "type": "zip", 406 | "url": "https://api.github.com/repos/guzzle/guzzle3/zipball/0645b70d953bc1c067bbc8d5bc53194706b628d9", 407 | "reference": "0645b70d953bc1c067bbc8d5bc53194706b628d9", 408 | "shasum": "" 409 | }, 410 | "require": { 411 | "ext-curl": "*", 412 | "php": ">=5.3.3", 413 | "symfony/event-dispatcher": "~2.1" 414 | }, 415 | "replace": { 416 | "guzzle/batch": "self.version", 417 | "guzzle/cache": "self.version", 418 | "guzzle/common": "self.version", 419 | "guzzle/http": "self.version", 420 | "guzzle/inflection": "self.version", 421 | "guzzle/iterator": "self.version", 422 | "guzzle/log": "self.version", 423 | "guzzle/parser": "self.version", 424 | "guzzle/plugin": "self.version", 425 | "guzzle/plugin-async": "self.version", 426 | "guzzle/plugin-backoff": "self.version", 427 | "guzzle/plugin-cache": "self.version", 428 | "guzzle/plugin-cookie": "self.version", 429 | "guzzle/plugin-curlauth": "self.version", 430 | "guzzle/plugin-error-response": "self.version", 431 | "guzzle/plugin-history": "self.version", 432 | "guzzle/plugin-log": "self.version", 433 | "guzzle/plugin-md5": "self.version", 434 | "guzzle/plugin-mock": "self.version", 435 | "guzzle/plugin-oauth": "self.version", 436 | "guzzle/service": "self.version", 437 | "guzzle/stream": "self.version" 438 | }, 439 | "require-dev": { 440 | "doctrine/cache": "~1.3", 441 | "monolog/monolog": "~1.0", 442 | "phpunit/phpunit": "3.7.*", 443 | "psr/log": "~1.0", 444 | "symfony/class-loader": "~2.1", 445 | "zendframework/zend-cache": "2.*,<2.3", 446 | "zendframework/zend-log": "2.*,<2.3" 447 | }, 448 | "suggest": { 449 | "guzzlehttp/guzzle": "Guzzle 5 has moved to a new package name. The package you have installed, Guzzle 3, is deprecated." 450 | }, 451 | "type": "library", 452 | "extra": { 453 | "branch-alias": { 454 | "dev-master": "3.9-dev" 455 | } 456 | }, 457 | "autoload": { 458 | "psr-0": { 459 | "Guzzle": "src/", 460 | "Guzzle\\Tests": "tests/" 461 | } 462 | }, 463 | "notification-url": "https://packagist.org/downloads/", 464 | "license": [ 465 | "MIT" 466 | ], 467 | "authors": [ 468 | { 469 | "name": "Michael Dowling", 470 | "email": "mtdowling@gmail.com", 471 | "homepage": "https://github.com/mtdowling" 472 | }, 473 | { 474 | "name": "Guzzle Community", 475 | "homepage": "https://github.com/guzzle/guzzle/contributors" 476 | } 477 | ], 478 | "description": "PHP HTTP client. This library is deprecated in favor of https://packagist.org/packages/guzzlehttp/guzzle", 479 | "homepage": "http://guzzlephp.org/", 480 | "keywords": [ 481 | "client", 482 | "curl", 483 | "framework", 484 | "http", 485 | "http client", 486 | "rest", 487 | "web service" 488 | ], 489 | "time": "2015-03-18 18:23:50" 490 | }, 491 | { 492 | "name": "satooshi/php-coveralls", 493 | "version": "v0.6.1", 494 | "source": { 495 | "type": "git", 496 | "url": "https://github.com/satooshi/php-coveralls.git", 497 | "reference": "dd0df95bd37a7cf5c5c50304dfe260ffe4b50760" 498 | }, 499 | "dist": { 500 | "type": "zip", 501 | "url": "https://api.github.com/repos/satooshi/php-coveralls/zipball/dd0df95bd37a7cf5c5c50304dfe260ffe4b50760", 502 | "reference": "dd0df95bd37a7cf5c5c50304dfe260ffe4b50760", 503 | "shasum": "" 504 | }, 505 | "require": { 506 | "ext-curl": "*", 507 | "ext-json": "*", 508 | "ext-simplexml": "*", 509 | "guzzle/guzzle": ">=3.0", 510 | "php": ">=5.3", 511 | "psr/log": "1.0.0", 512 | "symfony/config": ">=2.0", 513 | "symfony/console": ">=2.0", 514 | "symfony/stopwatch": ">=2.2", 515 | "symfony/yaml": ">=2.0" 516 | }, 517 | "require-dev": { 518 | "apigen/apigen": "2.8.*@stable", 519 | "pdepend/pdepend": "dev-master", 520 | "phpmd/phpmd": "dev-master", 521 | "phpunit/php-invoker": ">=1.1.0,<1.2.0", 522 | "phpunit/phpunit": "3.7.*@stable", 523 | "sebastian/finder-facade": "dev-master", 524 | "sebastian/phpcpd": "1.4.*@stable", 525 | "squizlabs/php_codesniffer": "1.4.*@stable", 526 | "theseer/fdomdocument": "dev-master" 527 | }, 528 | "bin": [ 529 | "composer/bin/coveralls" 530 | ], 531 | "type": "library", 532 | "autoload": { 533 | "psr-0": { 534 | "Contrib\\Component": "src/", 535 | "Contrib\\Bundle": "src/" 536 | } 537 | }, 538 | "notification-url": "https://packagist.org/downloads/", 539 | "license": [ 540 | "MIT" 541 | ], 542 | "authors": [ 543 | { 544 | "name": "Kitamura Satoshi", 545 | "email": "with.no.parachute@gmail.com", 546 | "homepage": "https://www.facebook.com/satooshi.jp" 547 | } 548 | ], 549 | "description": "PHP client library for Coveralls API", 550 | "homepage": "https://github.com/satooshi/php-coveralls", 551 | "keywords": [ 552 | "ci", 553 | "coverage", 554 | "github", 555 | "test" 556 | ], 557 | "time": "2013-05-04 08:07:33" 558 | }, 559 | { 560 | "name": "symfony/config", 561 | "version": "v2.7.1", 562 | "source": { 563 | "type": "git", 564 | "url": "https://github.com/symfony/Config.git", 565 | "reference": "58ded81f1f582a87c528ef3dae9a859f78b5f374" 566 | }, 567 | "dist": { 568 | "type": "zip", 569 | "url": "https://api.github.com/repos/symfony/Config/zipball/58ded81f1f582a87c528ef3dae9a859f78b5f374", 570 | "reference": "58ded81f1f582a87c528ef3dae9a859f78b5f374", 571 | "shasum": "" 572 | }, 573 | "require": { 574 | "php": ">=5.3.9", 575 | "symfony/filesystem": "~2.3" 576 | }, 577 | "require-dev": { 578 | "symfony/phpunit-bridge": "~2.7" 579 | }, 580 | "type": "library", 581 | "extra": { 582 | "branch-alias": { 583 | "dev-master": "2.7-dev" 584 | } 585 | }, 586 | "autoload": { 587 | "psr-4": { 588 | "Symfony\\Component\\Config\\": "" 589 | } 590 | }, 591 | "notification-url": "https://packagist.org/downloads/", 592 | "license": [ 593 | "MIT" 594 | ], 595 | "authors": [ 596 | { 597 | "name": "Fabien Potencier", 598 | "email": "fabien@symfony.com" 599 | }, 600 | { 601 | "name": "Symfony Community", 602 | "homepage": "https://symfony.com/contributors" 603 | } 604 | ], 605 | "description": "Symfony Config Component", 606 | "homepage": "https://symfony.com", 607 | "time": "2015-06-11 14:06:56" 608 | }, 609 | { 610 | "name": "symfony/console", 611 | "version": "v2.7.1", 612 | "source": { 613 | "type": "git", 614 | "url": "https://github.com/symfony/Console.git", 615 | "reference": "564398bc1f33faf92fc2ec86859983d30eb81806" 616 | }, 617 | "dist": { 618 | "type": "zip", 619 | "url": "https://api.github.com/repos/symfony/Console/zipball/564398bc1f33faf92fc2ec86859983d30eb81806", 620 | "reference": "564398bc1f33faf92fc2ec86859983d30eb81806", 621 | "shasum": "" 622 | }, 623 | "require": { 624 | "php": ">=5.3.9" 625 | }, 626 | "require-dev": { 627 | "psr/log": "~1.0", 628 | "symfony/event-dispatcher": "~2.1", 629 | "symfony/phpunit-bridge": "~2.7", 630 | "symfony/process": "~2.1" 631 | }, 632 | "suggest": { 633 | "psr/log": "For using the console logger", 634 | "symfony/event-dispatcher": "", 635 | "symfony/process": "" 636 | }, 637 | "type": "library", 638 | "extra": { 639 | "branch-alias": { 640 | "dev-master": "2.7-dev" 641 | } 642 | }, 643 | "autoload": { 644 | "psr-4": { 645 | "Symfony\\Component\\Console\\": "" 646 | } 647 | }, 648 | "notification-url": "https://packagist.org/downloads/", 649 | "license": [ 650 | "MIT" 651 | ], 652 | "authors": [ 653 | { 654 | "name": "Fabien Potencier", 655 | "email": "fabien@symfony.com" 656 | }, 657 | { 658 | "name": "Symfony Community", 659 | "homepage": "https://symfony.com/contributors" 660 | } 661 | ], 662 | "description": "Symfony Console Component", 663 | "homepage": "https://symfony.com", 664 | "time": "2015-06-10 15:30:22" 665 | }, 666 | { 667 | "name": "symfony/event-dispatcher", 668 | "version": "v2.7.1", 669 | "source": { 670 | "type": "git", 671 | "url": "https://github.com/symfony/EventDispatcher.git", 672 | "reference": "be3c5ff8d503c46768aeb78ce6333051aa6f26d9" 673 | }, 674 | "dist": { 675 | "type": "zip", 676 | "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/be3c5ff8d503c46768aeb78ce6333051aa6f26d9", 677 | "reference": "be3c5ff8d503c46768aeb78ce6333051aa6f26d9", 678 | "shasum": "" 679 | }, 680 | "require": { 681 | "php": ">=5.3.9" 682 | }, 683 | "require-dev": { 684 | "psr/log": "~1.0", 685 | "symfony/config": "~2.0,>=2.0.5", 686 | "symfony/dependency-injection": "~2.6", 687 | "symfony/expression-language": "~2.6", 688 | "symfony/phpunit-bridge": "~2.7", 689 | "symfony/stopwatch": "~2.3" 690 | }, 691 | "suggest": { 692 | "symfony/dependency-injection": "", 693 | "symfony/http-kernel": "" 694 | }, 695 | "type": "library", 696 | "extra": { 697 | "branch-alias": { 698 | "dev-master": "2.7-dev" 699 | } 700 | }, 701 | "autoload": { 702 | "psr-4": { 703 | "Symfony\\Component\\EventDispatcher\\": "" 704 | } 705 | }, 706 | "notification-url": "https://packagist.org/downloads/", 707 | "license": [ 708 | "MIT" 709 | ], 710 | "authors": [ 711 | { 712 | "name": "Fabien Potencier", 713 | "email": "fabien@symfony.com" 714 | }, 715 | { 716 | "name": "Symfony Community", 717 | "homepage": "https://symfony.com/contributors" 718 | } 719 | ], 720 | "description": "Symfony EventDispatcher Component", 721 | "homepage": "https://symfony.com", 722 | "time": "2015-06-08 09:37:21" 723 | }, 724 | { 725 | "name": "symfony/filesystem", 726 | "version": "v2.7.1", 727 | "source": { 728 | "type": "git", 729 | "url": "https://github.com/symfony/Filesystem.git", 730 | "reference": "a0d43eb3e17d4f4c6990289805a488a0482a07f3" 731 | }, 732 | "dist": { 733 | "type": "zip", 734 | "url": "https://api.github.com/repos/symfony/Filesystem/zipball/a0d43eb3e17d4f4c6990289805a488a0482a07f3", 735 | "reference": "a0d43eb3e17d4f4c6990289805a488a0482a07f3", 736 | "shasum": "" 737 | }, 738 | "require": { 739 | "php": ">=5.3.9" 740 | }, 741 | "require-dev": { 742 | "symfony/phpunit-bridge": "~2.7" 743 | }, 744 | "type": "library", 745 | "extra": { 746 | "branch-alias": { 747 | "dev-master": "2.7-dev" 748 | } 749 | }, 750 | "autoload": { 751 | "psr-4": { 752 | "Symfony\\Component\\Filesystem\\": "" 753 | } 754 | }, 755 | "notification-url": "https://packagist.org/downloads/", 756 | "license": [ 757 | "MIT" 758 | ], 759 | "authors": [ 760 | { 761 | "name": "Fabien Potencier", 762 | "email": "fabien@symfony.com" 763 | }, 764 | { 765 | "name": "Symfony Community", 766 | "homepage": "https://symfony.com/contributors" 767 | } 768 | ], 769 | "description": "Symfony Filesystem Component", 770 | "homepage": "https://symfony.com", 771 | "time": "2015-06-08 09:37:21" 772 | }, 773 | { 774 | "name": "symfony/stopwatch", 775 | "version": "v2.7.1", 776 | "source": { 777 | "type": "git", 778 | "url": "https://github.com/symfony/Stopwatch.git", 779 | "reference": "c653f1985f6c2b7dbffd04d48b9c0a96aaef814b" 780 | }, 781 | "dist": { 782 | "type": "zip", 783 | "url": "https://api.github.com/repos/symfony/Stopwatch/zipball/c653f1985f6c2b7dbffd04d48b9c0a96aaef814b", 784 | "reference": "c653f1985f6c2b7dbffd04d48b9c0a96aaef814b", 785 | "shasum": "" 786 | }, 787 | "require": { 788 | "php": ">=5.3.9" 789 | }, 790 | "require-dev": { 791 | "symfony/phpunit-bridge": "~2.7" 792 | }, 793 | "type": "library", 794 | "extra": { 795 | "branch-alias": { 796 | "dev-master": "2.7-dev" 797 | } 798 | }, 799 | "autoload": { 800 | "psr-4": { 801 | "Symfony\\Component\\Stopwatch\\": "" 802 | } 803 | }, 804 | "notification-url": "https://packagist.org/downloads/", 805 | "license": [ 806 | "MIT" 807 | ], 808 | "authors": [ 809 | { 810 | "name": "Fabien Potencier", 811 | "email": "fabien@symfony.com" 812 | }, 813 | { 814 | "name": "Symfony Community", 815 | "homepage": "https://symfony.com/contributors" 816 | } 817 | ], 818 | "description": "Symfony Stopwatch Component", 819 | "homepage": "https://symfony.com", 820 | "time": "2015-06-04 20:11:48" 821 | }, 822 | { 823 | "name": "symfony/yaml", 824 | "version": "v2.7.1", 825 | "source": { 826 | "type": "git", 827 | "url": "https://github.com/symfony/Yaml.git", 828 | "reference": "9808e75c609a14f6db02f70fccf4ca4aab53c160" 829 | }, 830 | "dist": { 831 | "type": "zip", 832 | "url": "https://api.github.com/repos/symfony/Yaml/zipball/9808e75c609a14f6db02f70fccf4ca4aab53c160", 833 | "reference": "9808e75c609a14f6db02f70fccf4ca4aab53c160", 834 | "shasum": "" 835 | }, 836 | "require": { 837 | "php": ">=5.3.9" 838 | }, 839 | "require-dev": { 840 | "symfony/phpunit-bridge": "~2.7" 841 | }, 842 | "type": "library", 843 | "extra": { 844 | "branch-alias": { 845 | "dev-master": "2.7-dev" 846 | } 847 | }, 848 | "autoload": { 849 | "psr-4": { 850 | "Symfony\\Component\\Yaml\\": "" 851 | } 852 | }, 853 | "notification-url": "https://packagist.org/downloads/", 854 | "license": [ 855 | "MIT" 856 | ], 857 | "authors": [ 858 | { 859 | "name": "Fabien Potencier", 860 | "email": "fabien@symfony.com" 861 | }, 862 | { 863 | "name": "Symfony Community", 864 | "homepage": "https://symfony.com/contributors" 865 | } 866 | ], 867 | "description": "Symfony Yaml Component", 868 | "homepage": "https://symfony.com", 869 | "time": "2015-06-10 15:30:22" 870 | } 871 | ], 872 | "aliases": [], 873 | "minimum-stability": "stable", 874 | "stability-flags": [], 875 | "prefer-stable": false, 876 | "prefer-lowest": false, 877 | "platform": { 878 | "php": ">=5.4.0" 879 | }, 880 | "platform-dev": [] 881 | } 882 | -------------------------------------------------------------------------------- /config/Common.php: -------------------------------------------------------------------------------- 1 | 6 | * @license MIT License 7 | * @copyright 2015 Kenji Suzuki 8 | * @link https://github.com/kenjis/codeigniter-cli 9 | */ 10 | 11 | namespace Kenjis\CodeIgniter_Cli\_Config; 12 | 13 | use Aura\Di\Config; 14 | use Aura\Di\Container; 15 | use Kenjis\CodeIgniter_Cli\UserConfig; 16 | 17 | class Common extends Config 18 | { 19 | /** 20 | * @var array list of built-in commands 21 | */ 22 | private $commands = [ 23 | 'Seed', 'Migrate', 'Generate', 'Run', 24 | ]; 25 | 26 | private $user_command_paths = []; 27 | 28 | public function define(Container $di) 29 | { 30 | $di->set('aura/project-kernel:logger', $di->newInstance('Monolog\Logger')); 31 | 32 | /* @var $ci \CI_Controller */ 33 | $ci =& get_instance(); 34 | 35 | // register built-in command classes 36 | foreach ($this->commands as $command) { 37 | $class = 'Kenjis\CodeIgniter_Cli\Command\\' . $command; 38 | $di->params[$class] = [ 39 | 'context' => $di->lazyGet('aura/cli-kernel:context'), 40 | 'stdio' => $di->lazyGet('aura/cli-kernel:stdio'), 41 | 'ci' => $ci, 42 | ]; 43 | } 44 | 45 | $seeder_path = APPPATH . 'database/seeds/'; 46 | $di->setter['Kenjis\CodeIgniter_Cli\Command\Seed']['setSeederPath'] 47 | = $seeder_path; 48 | 49 | $this->user_command_paths = [ APPPATH . 'commands/' ]; 50 | // register user command classes 51 | UserConfig::registerCommandClasses($di, $ci, $this->user_command_paths); 52 | } 53 | 54 | public function modify(Container $di) 55 | { 56 | $this->modifyLogger($di); 57 | $this->modifyCliDispatcherAndHelp($di); 58 | } 59 | 60 | protected function modifyLogger(Container $di) 61 | { 62 | $project = $di->get('project'); 63 | $mode = $project->getMode(); 64 | $file = $project->getPath("tmp/log/{$mode}.log"); 65 | 66 | $logger = $di->get('aura/project-kernel:logger'); 67 | $logger->pushHandler($di->newInstance( 68 | 'Monolog\Handler\StreamHandler', 69 | array( 70 | 'stream' => $file, 71 | ) 72 | )); 73 | } 74 | 75 | protected function modifyCliDispatcherAndHelp(Container $di) 76 | { 77 | // $context = $di->get('aura/cli-kernel:context'); 78 | // $stdio = $di->get('aura/cli-kernel:stdio'); 79 | // $logger = $di->get('aura/project-kernel:logger'); 80 | $dispatcher = $di->get('aura/cli-kernel:dispatcher'); 81 | $help_service = $di->get('aura/cli-kernel:help_service'); 82 | 83 | // register built-in commands 84 | foreach ($this->commands as $command) { 85 | $class = 'Kenjis\CodeIgniter_Cli\Command\\' . $command; 86 | $command_name = strtolower($command); 87 | $dispatcher->setObject( 88 | $command_name, 89 | $di->lazyNew($class) 90 | ); 91 | 92 | $help_class = 'Kenjis\CodeIgniter_Cli\Command\\' . $command . 'Help'; 93 | $help_service->set( 94 | $command_name, 95 | $di->lazyNew($help_class) 96 | ); 97 | } 98 | 99 | // register user commands 100 | UserConfig::registerCommands( 101 | $di, $dispatcher, $help_service, $this->user_command_paths 102 | ); 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /config/Dev.php: -------------------------------------------------------------------------------- 1 | 6 | * @license MIT License 7 | * @copyright 2015 Kenji Suzuki 8 | * @link https://github.com/kenjis/codeigniter-cli 9 | */ 10 | 11 | namespace Kenjis\CodeIgniter_Cli\_Config; 12 | 13 | use Aura\Di\Config; 14 | use Aura\Di\Container; 15 | 16 | class Dev extends Config 17 | { 18 | public function define(Container $di) 19 | { 20 | ini_set('error_reporting', E_ALL); 21 | ini_set('display_errors', true); 22 | } 23 | 24 | public function modify(Container $di) 25 | { 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /config/Prod.php: -------------------------------------------------------------------------------- 1 | 6 | * @license MIT License 7 | * @copyright 2015 Kenji Suzuki 8 | * @link https://github.com/kenjis/codeigniter-cli 9 | */ 10 | 11 | namespace Kenjis\CodeIgniter_Cli\_Config; 12 | 13 | use Aura\Di\Config; 14 | use Aura\Di\Container; 15 | 16 | class Prod extends Config 17 | { 18 | public function define(Container $di) 19 | { 20 | } 21 | 22 | public function modify(Container $di) 23 | { 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /config/Test.php: -------------------------------------------------------------------------------- 1 | 6 | * @license MIT License 7 | * @copyright 2015 Kenji Suzuki 8 | * @link https://github.com/kenjis/codeigniter-cli 9 | */ 10 | 11 | namespace Kenjis\CodeIgniter_Cli\_Config; 12 | 13 | use Aura\Di\Config; 14 | use Aura\Di\Container; 15 | 16 | class Test extends Config 17 | { 18 | public function define(Container $di) 19 | { 20 | } 21 | 22 | public function modify(Container $di) 23 | { 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /config/_env.php: -------------------------------------------------------------------------------- 1 | 7 | * @license MIT License 8 | * @copyright 2015 Kenji Suzuki 9 | * @link https://github.com/kenjis/codeigniter-cli 10 | */ 11 | 12 | if (isset($_ENV['CI_ENV'])) { 13 | switch ($_ENV['CI_ENV']) { 14 | case 'development': 15 | $_ENV['AURA_CONFIG_MODE'] = 'dev'; 16 | break; 17 | case 'testing': 18 | $_ENV['AURA_CONFIG_MODE'] = 'test'; 19 | break; 20 | case 'production': 21 | $_ENV['AURA_CONFIG_MODE'] = 'prod'; 22 | break; 23 | default: 24 | $_ENV['AURA_CONFIG_MODE'] = 'dev'; 25 | } 26 | } 27 | 28 | // set the mode here only if it is not already set. 29 | // this allows for setting via shell variables, integration testing, etc. 30 | if (! isset($_ENV['AURA_CONFIG_MODE'])) { 31 | $_ENV['AURA_CONFIG_MODE'] = 'dev'; 32 | } 33 | -------------------------------------------------------------------------------- /install.php: -------------------------------------------------------------------------------- 1 | 6 | * @license MIT License 7 | * @copyright 2015 Kenji Suzuki 8 | * @link https://github.com/kenjis/codeigniter-cli 9 | */ 10 | 11 | $installer = new Installer(); 12 | $installer->install(); 13 | 14 | class Installer 15 | { 16 | public static function install() 17 | { 18 | self::recursiveCopy('vendor/kenjis/codeigniter-cli/config', 'config'); 19 | 20 | @mkdir('tmp', 0755); 21 | @mkdir('tmp/log', 0755); 22 | 23 | self::copy('vendor/kenjis/codeigniter-cli/cli', 'cli'); 24 | self::copy('vendor/kenjis/codeigniter-cli/ci_instance.php', 'ci_instance.php'); 25 | 26 | chmod('cli', 0755); 27 | } 28 | 29 | private static function copy($src, $dst) 30 | { 31 | $success = copy($src, $dst); 32 | if ($success) { 33 | echo 'copied: ' . $dst . PHP_EOL; 34 | } 35 | } 36 | 37 | /** 38 | * Recursive Copy 39 | * 40 | * @param string $src 41 | * @param string $dst 42 | */ 43 | private static function recursiveCopy($src, $dst) 44 | { 45 | @mkdir($dst, 0755); 46 | 47 | $iterator = new \RecursiveIteratorIterator( 48 | new \RecursiveDirectoryIterator($src, \RecursiveDirectoryIterator::SKIP_DOTS), 49 | \RecursiveIteratorIterator::SELF_FIRST 50 | ); 51 | 52 | foreach ($iterator as $file) { 53 | if ($file->isDir()) { 54 | @mkdir($dst . '/' . $iterator->getSubPathName()); 55 | } else { 56 | $success = copy($file, $dst . '/' . $iterator->getSubPathName()); 57 | if ($success) { 58 | echo 'copied: ' . $dst . '/' . $iterator->getSubPathName() . PHP_EOL; 59 | } 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /phpunit.php: -------------------------------------------------------------------------------- 1 | 'sqlite:' . __DIR__ . '/tests/data/sqlite-database.db', 37 | 'username' => '', 38 | 'password' => '', 39 | 'database' => '', 40 | 'dbdriver' => 'pdo', 41 | 'dbprefix' => '', 42 | 'pconnect' => true, 43 | 'db_debug' => true, 44 | 'cache_on' => false, 45 | 'cachedir' => '', 46 | 'char_set' => 'utf8', 47 | 'dbcollat' => 'utf8_general_ci', 48 | 'swap_pre' => '', 49 | 'stricton' => false, 50 | ]; 51 | $ci->load->database($config); 52 | 53 | // change migration config 54 | $config = [ 55 | 'migration_enabled' => true, 56 | 'migration_type' => 'timestamp', 57 | 'migration_table' => 'migrations', 58 | 'migration_auto_latest' => false, 59 | 'migration_version' => 20150429110003, 60 | 'migration_path' => __DIR__ . '/tests/Fake/migrations/', 61 | ]; 62 | $ci->load->library('migration', $config); 63 | -------------------------------------------------------------------------------- /phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | tests 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | src 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/.placeholder: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kenjis/codeigniter-cli/7c4990eae6a59be26e819841b2853d11fc927fad/src/.placeholder -------------------------------------------------------------------------------- /src/Command/Command.php: -------------------------------------------------------------------------------- 1 | 6 | * @license MIT License 7 | * @copyright 2015 Kenji Suzuki 8 | * @link https://github.com/kenjis/codeigniter-cli 9 | */ 10 | 11 | namespace Kenjis\CodeIgniter_Cli\Command; 12 | 13 | use Aura\Cli\Stdio; 14 | use Aura\Cli\Context; 15 | use CI_Controller; 16 | use RuntimeException; 17 | 18 | abstract class Command 19 | { 20 | protected $context; 21 | protected $stdio; 22 | protected $ci; 23 | protected $db; 24 | protected $dbforge; 25 | 26 | public function __construct(Context $context, Stdio $stdio, CI_Controller $ci) 27 | { 28 | $this->context = $context; 29 | $this->stdio = $stdio; 30 | $this->ci = $ci; 31 | 32 | $this->ci->load->database(); 33 | $this->db = $this->ci->db; 34 | $this->ci->load->dbforge(); 35 | $this->dbforge = $this->ci->dbforge; 36 | } 37 | 38 | public function __get($property) 39 | { 40 | if (! property_exists($this->ci, $property)) { 41 | ob_start(); 42 | var_dump(debug_backtrace()); 43 | $backtrace = ob_get_clean(); 44 | file_put_contents(ROOTPATH . '/tmp/backtrace.log', $backtrace, LOCK_EX); 45 | $this->stdio->errln( 46 | '<>No such property: ' . $property . ' in CodeIgniter instance<>' 47 | ); 48 | $this->stdio->errln('Backtrace was saved in tmp/backtrace.log'); 49 | throw new RuntimeException('Property does not exist'); 50 | } 51 | 52 | return $this->ci->$property; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/Command/Generate.php: -------------------------------------------------------------------------------- 1 | 6 | * @license MIT License 7 | * @copyright 2015 Kenji Suzuki 8 | * @link https://github.com/kenjis/codeigniter-cli 9 | */ 10 | 11 | namespace Kenjis\CodeIgniter_Cli\Command; 12 | 13 | use Aura\Cli\Status; 14 | 15 | class Generate extends Command 16 | { 17 | public function __invoke($type, $classname = null) 18 | { 19 | $generator = __NAMESPACE__ . '\\Generate\\' . ucfirst($type); 20 | if (! class_exists($generator)) { 21 | $this->stdio->errln( 22 | '<>No such generator class: ' . $generator . '<>' 23 | ); 24 | return Status::FAILURE; 25 | } 26 | 27 | $command = new $generator($this->context, $this->stdio, $this->ci); 28 | return $command($type, $classname); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Command/Generate/Migration.php: -------------------------------------------------------------------------------- 1 | 6 | * @license MIT License 7 | * @copyright 2015 Kenji Suzuki 8 | * @link https://github.com/kenjis/codeigniter-cli 9 | */ 10 | 11 | namespace Kenjis\CodeIgniter_Cli\Command\Generate; 12 | 13 | use Aura\Cli\Stdio; 14 | use Aura\Cli\Context; 15 | use Aura\Cli\Status; 16 | use Kenjis\CodeIgniter_Cli\Command\Command; 17 | use CI_Controller; 18 | 19 | /** 20 | * @property \CI_Loader $load 21 | * @property \CI_Config $config 22 | */ 23 | class Migration extends Command 24 | { 25 | public function __construct(Context $context, Stdio $stdio, CI_Controller $ci) 26 | { 27 | parent::__construct($context, $stdio, $ci); 28 | $this->load->config('migration'); 29 | } 30 | 31 | /** 32 | * @param string $type 33 | * @param string $classname 34 | */ 35 | public function __invoke($type, $classname) 36 | { 37 | if ($classname === null) { 38 | $this->stdio->errln( 39 | '<>Classname is needed<>' 40 | ); 41 | $this->stdio->errln( 42 | ' eg, generate migration CreateUserTable' 43 | ); 44 | return Status::USAGE; 45 | } 46 | 47 | $migration_path = $this->config->item('migration_path'); 48 | $migration_type = $this->config->item('migration_type'); 49 | 50 | $file_path = $this->generateFilename( 51 | $migration_path, $migration_type, $classname 52 | ); 53 | 54 | // check file exist 55 | if (file_exists($file_path)) { 56 | $this->stdio->errln( 57 | "<>The file \"$file_path\" already exists<>" 58 | ); 59 | return Status::FAILURE; 60 | } 61 | 62 | // check class exist 63 | foreach (glob($migration_path . '*_*.php') as $file) { 64 | $name = basename($file, '.php'); 65 | if (preg_match($migration_type === 'timestamp' ? '/^\d{14}_(\w+)$/' : '/^\d{3}_(\w+)$/', $name, $match)) { 66 | if (strtolower($match[1]) === strtolower($classname)) { 67 | $this->stdio->errln( 68 | "<>The Class \"$match[1]\" already exists<>" 69 | ); 70 | return Status::FAILURE; 71 | } 72 | } 73 | } 74 | 75 | $template = file_get_contents(__DIR__ . '/templates/Migration.txt'); 76 | $search = [ 77 | '@@classname@@', 78 | '@@date@@', 79 | ]; 80 | $replace = [ 81 | $classname, 82 | date('Y/m/d H:i:s'), 83 | ]; 84 | $output = str_replace($search, $replace, $template); 85 | $generated = @file_put_contents($file_path, $output, LOCK_EX); 86 | 87 | if ($generated !== false) { 88 | $this->stdio->outln('<>Generated: ' . $file_path . '<>'); 89 | } else { 90 | $this->stdio->errln( 91 | "<>Can't write to \"$file_path\"<>" 92 | ); 93 | return Status::FAILURE; 94 | } 95 | } 96 | 97 | private function generateFilename($migration_path, $migration_type, $classname) 98 | { 99 | if ($migration_type === 'sequential') { 100 | $migrations = []; 101 | 102 | // find max version 103 | foreach (glob($migration_path . '*_*.php') as $file) { 104 | $name = basename($file, '.php'); 105 | 106 | if (preg_match('/^\d{3}_(\w+)$/', $name)) { 107 | $number = sscanf($name, '%[0-9]+', $number) ? $number : '0'; 108 | $migrations[] = $number; 109 | } 110 | } 111 | 112 | $version = 0; 113 | if ($migrations !== []) { 114 | $version = max($migrations); 115 | } 116 | 117 | return $migration_path . sprintf('%03d', ++$version) . '_' . $classname . '.php'; 118 | } 119 | 120 | return $migration_path . date('YmdHis') . '_' . $classname . '.php'; 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /src/Command/Generate/templates/Migration.txt: -------------------------------------------------------------------------------- 1 | 6 | * Created on: @@date@@ 7 | */ 8 | class Migration_@@classname@@ extends CI_Migration { 9 | 10 | public function up() 11 | { 12 | // // Creating a table 13 | // $this->dbforge->add_field(array( 14 | // 'blog_id' => array( 15 | // 'type' => 'INT', 16 | // 'constraint' => 11, 17 | // 'auto_increment' => TRUE 18 | // ), 19 | // 'blog_title' => array( 20 | // 'type' => 'VARCHAR', 21 | // 'constraint' => 100, 22 | // ), 23 | // 'blog_author' => array( 24 | // 'type' =>'VARCHAR', 25 | // 'constraint' => '100', 26 | // 'default' => 'King of Town', 27 | // ), 28 | // 'blog_description' => array( 29 | // 'type' => 'TEXT', 30 | // 'null' => TRUE, 31 | // ), 32 | // )); 33 | // $this->dbforge->add_key('blog_id', TRUE); 34 | // $this->dbforge->create_table('blog'); 35 | 36 | // // Adding a Column to a Table 37 | // $fields = array( 38 | // 'preferences' => array('type' => 'TEXT') 39 | // ); 40 | // $this->dbforge->add_column('table_name', $fields); 41 | } 42 | 43 | public function down() 44 | { 45 | // // Dropping a table 46 | // $this->dbforge->drop_table('blog'); 47 | 48 | // // Dropping a Column From a Table 49 | // $this->dbforge->drop_column('table_name', 'column_to_drop'); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/Command/GenerateHelp.php: -------------------------------------------------------------------------------- 1 | 6 | * @license MIT License 7 | * @copyright 2015 Kenji Suzuki 8 | * @link https://github.com/kenjis/codeigniter-cli 9 | */ 10 | 11 | namespace Kenjis\CodeIgniter_Cli\Command; 12 | 13 | use Aura\Cli\Help; 14 | 15 | class GenerateHelp extends Help 16 | { 17 | public function init() 18 | { 19 | $this->setSummary('Generate code.'); 20 | $this->setUsage('migration '); 21 | $this->setUsage([ 22 | 'migration Generate migration file skeleton', 23 | ]); 24 | $this->setDescr( 25 | '<>generate<> command generates code.' . PHP_EOL 26 | . ' eg, generate migration Create_user_table' 27 | ); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Command/Migrate.php: -------------------------------------------------------------------------------- 1 | 6 | * @license MIT License 7 | * @copyright 2015 Kenji Suzuki 8 | * @link https://github.com/kenjis/codeigniter-cli 9 | */ 10 | 11 | namespace Kenjis\CodeIgniter_Cli\Command; 12 | 13 | use Aura\Cli\Status; 14 | 15 | /** 16 | * @property \CI_Migration $migration 17 | * @property \CI_Loader $load 18 | * @property \CI_Config $config 19 | */ 20 | class Migrate extends Command 21 | { 22 | public function __invoke($command = null) 23 | { 24 | $this->load->library('migration'); 25 | $this->load->config('migration'); 26 | 27 | if ($command === 'status') { 28 | $this->listMigrationFiles(); 29 | return; 30 | } 31 | 32 | if ($command === 'version') { 33 | $this->showVersions(); 34 | return; 35 | } 36 | 37 | // if argument is digits, migrate to the version 38 | if (ctype_digit($command)) { 39 | if ($this->migrateToVersion($command) === false) { 40 | return Status::FAILURE; 41 | } else { 42 | $this->showVersions(); 43 | return; 44 | } 45 | } 46 | 47 | if ($command !== null) { 48 | $this->stdio->errln( 49 | '<>No such command: ' . $command . '<>' 50 | ); 51 | return Status::USAGE; 52 | } 53 | 54 | // if no argument, migrate to current 55 | if ($this->migration->current() === false) { 56 | $this->stdio->errln( 57 | '<>' . $this->migration->error_string() . '<>' 58 | ); 59 | return Status::FAILURE; 60 | } else { 61 | $this->showVersions(); 62 | } 63 | } 64 | 65 | private function migrateToVersion($version) 66 | { 67 | if ($this->migration->version($version) === false) { 68 | $this->stdio->errln( 69 | '<>' . $this->migration->error_string() . '<>' 70 | ); 71 | return false; 72 | } 73 | 74 | return true; 75 | } 76 | 77 | private function getDbVersion() 78 | { 79 | $row = $this->db->select('version')->get($this->config->item('migration_table'))->row(); 80 | return $row ? $row->version : '0'; 81 | } 82 | 83 | private function showVersions() 84 | { 85 | $this->stdio->outln( 86 | ' current: <>' . $this->config->item('migration_version') . '<>' 87 | . ' (in config/migration.php)' 88 | ); 89 | $version = $this->getDbVersion(); 90 | $this->stdio->outln( 91 | 'database: <>' . $version . '<>' 92 | . ' (in database table)' 93 | ); 94 | $version = $this->getLatestVersion(); 95 | $this->stdio->outln( 96 | ' latest: ' . $version . '' 97 | . ' (in migration files)' 98 | ); 99 | } 100 | 101 | private function getLatestVersion() 102 | { 103 | $files = $this->migration->find_migrations(); 104 | 105 | if ($files === []) { 106 | return 'null'; 107 | } 108 | 109 | end($files); 110 | return key($files); 111 | } 112 | 113 | private function listMigrationFiles() 114 | { 115 | $this->stdio->outln( 116 | $this->config->item('migration_path') 117 | ); 118 | 119 | $current = $this->config->item('migration_version'); 120 | $db = $this->getDbVersion(); 121 | 122 | $files = $this->migration->find_migrations(); 123 | foreach ($files as $v => $file) { 124 | if ($v == $current && $v == $db) { 125 | $this->stdio->outln( 126 | ' <>' . basename($file) .' (current/database)<>' 127 | ); 128 | } elseif ($v == $current) { 129 | $this->stdio->outln( 130 | ' <>' . basename($file) .' (current)<>' 131 | ); 132 | } elseif ($v == $db) { 133 | $this->stdio->outln( 134 | ' <>' . basename($file) .' (database)<>' 135 | ); 136 | } else { 137 | $this->stdio->outln(' ' . basename($file)); 138 | } 139 | } 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /src/Command/MigrateHelp.php: -------------------------------------------------------------------------------- 1 | 6 | * @license MIT License 7 | * @copyright 2015 Kenji Suzuki 8 | * @link https://github.com/kenjis/codeigniter-cli 9 | */ 10 | 11 | namespace Kenjis\CodeIgniter_Cli\Command; 12 | 13 | use Aura\Cli\Help; 14 | 15 | class MigrateHelp extends Help 16 | { 17 | public function init() 18 | { 19 | $this->setSummary('Runs the migrations.'); 20 | $this->setUsage([ 21 | ' Migrate up to the current version.', 22 | ' Migrate up to the version.', 23 | 'status List all migration files and versions.', 24 | 'version Show migration versions.' 25 | ]); 26 | $this->setDescr( 27 | '<>migrate<> command runs the migrations and shows its status.' . PHP_EOL 28 | ); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Command/Run.php: -------------------------------------------------------------------------------- 1 | 6 | * @license MIT License 7 | * @copyright 2015 Kenji Suzuki 8 | * @link https://github.com/kenjis/codeigniter-cli 9 | */ 10 | 11 | namespace Kenjis\CodeIgniter_Cli\Command; 12 | 13 | use Aura\Cli\Status; 14 | 15 | class Run extends Command 16 | { 17 | public function __invoke($controller = null, $method = null) 18 | { 19 | if ($controller === null) { 20 | $this->stdio->errln('<>Controller is needed<>'); 21 | return Status::USAGE; 22 | } 23 | 24 | $argv = $this->context->argv->get(); 25 | array_shift($argv); 26 | array_shift($argv); 27 | array_shift($argv); 28 | array_shift($argv); 29 | $arguments = implode(' ', $argv); 30 | 31 | $console = FCPATH . 'index.php'; 32 | $this->stdio->outln( 33 | "<>php {$console} {$controller} {$method} {$arguments}<>" 34 | ); 35 | passthru("php {$console} {$controller} {$method} {$arguments}"); 36 | $this->stdio->outln(''); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Command/RunHelp.php: -------------------------------------------------------------------------------- 1 | 6 | * @license MIT License 7 | * @copyright 2015 Kenji Suzuki 8 | * @link https://github.com/kenjis/codeigniter-cli 9 | */ 10 | 11 | namespace Kenjis\CodeIgniter_Cli\Command; 12 | 13 | use Aura\Cli\Help; 14 | 15 | class RunHelp extends Help 16 | { 17 | public function init() 18 | { 19 | $this->setSummary('Run controller.'); 20 | $this->setUsage(' [ [ [ [...]]]]'); 21 | $this->setUsage([ 22 | '', 23 | ' ', 24 | ' ', 25 | ' [...]', 26 | ]); 27 | $this->setDescr( 28 | 'Run controller via the CLI.' 29 | ); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Command/Seed.php: -------------------------------------------------------------------------------- 1 | 6 | * @license MIT License 7 | * @copyright 2015 Kenji Suzuki 8 | * @link https://github.com/kenjis/codeigniter-cli 9 | */ 10 | 11 | namespace Kenjis\CodeIgniter_Cli\Command; 12 | 13 | use Aura\Cli\Stdio; 14 | use Aura\Cli\Context; 15 | use Aura\Cli\Status; 16 | use CI_Controller; 17 | 18 | class Seed extends Command 19 | { 20 | private $seeder_path; 21 | 22 | public function __construct(Context $context, Stdio $stdio, CI_Controller $ci) 23 | { 24 | parent::__construct($context, $stdio, $ci); 25 | } 26 | 27 | /** 28 | * @param string $seeder_path directory of seeder files 29 | */ 30 | public function setSeederPath($seeder_path) 31 | { 32 | $this->seeder_path = $seeder_path; 33 | } 34 | 35 | /** 36 | * @param string $class class name 37 | */ 38 | public function __invoke($class = null) 39 | { 40 | $options =[ 41 | 'l', // short flag -l, parameter is not allowed 42 | 'list', // long option --list, parameter is not allowed 43 | ]; 44 | $getopt = $this->context->getopt($options); 45 | $list = $getopt->get('-l', false) || $getopt->get('--list', false); 46 | 47 | if ($list) { 48 | $this->listSeederFiles(); 49 | return; 50 | } 51 | 52 | if ($class === null) { 53 | $seeder_list = $this->findSeeder(); 54 | } else { 55 | $seeder_list = [$this->seeder_path . $class . '.php']; 56 | } 57 | 58 | $this->runSeederList($seeder_list); 59 | } 60 | 61 | /** 62 | * run another seeder 63 | * 64 | * @param string $class class name 65 | */ 66 | public function call($class) 67 | { 68 | $seeder_list = [$this->seeder_path . $class . '.php']; 69 | $this->runSeederList($seeder_list); 70 | } 71 | 72 | private function runSeederList($seeder_list) 73 | { 74 | foreach ($seeder_list as $file) { 75 | if (! is_readable($file)) { 76 | $this->stdio->errln('<>Can\'t read: ' . $file . '<>'); 77 | break; 78 | } 79 | require_once $file; 80 | $classname = basename($file, '.php'); 81 | if (! class_exists($classname)) { 82 | $this->stdio->errln( 83 | '<>No such class: ' . $classname . ' in ' . $file . '<>' 84 | . ' [' . __METHOD__ . ': line ' . __LINE__ . ']' 85 | ); 86 | break; 87 | } 88 | $seeder = new $classname($this->context, $this->stdio, $this->ci); 89 | $seeder->setSeederPath($this->seeder_path); 90 | $this->runSeed($seeder); 91 | $this->stdio->outln('<>Seeded: ' . $classname . '<>'); 92 | } 93 | } 94 | 95 | private function listSeederFiles() 96 | { 97 | $seeder_list = $this->findSeeder(); 98 | foreach ($seeder_list as $file) { 99 | if (is_readable($file)) { 100 | $this->stdio->outln(' <>' . $file . '<>'); 101 | } 102 | } 103 | } 104 | 105 | private function runSeed($seeder) 106 | { 107 | $seeder->run(); 108 | } 109 | 110 | private function findSeeder() 111 | { 112 | $seeders = []; 113 | foreach (glob($this->seeder_path . '*.php') as $file) { 114 | $seeders[] = $file; 115 | } 116 | return $seeders; 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /src/Command/SeedHelp.php: -------------------------------------------------------------------------------- 1 | 6 | * @license MIT License 7 | * @copyright 2015 Kenji Suzuki 8 | * @link https://github.com/kenjis/codeigniter-cli 9 | */ 10 | 11 | namespace Kenjis\CodeIgniter_Cli\Command; 12 | 13 | use Aura\Cli\Help; 14 | 15 | class SeedHelp extends Help 16 | { 17 | public function init() 18 | { 19 | $this->setSummary('Seed the database with records.'); 20 | $this->setUsage([ 21 | '', 22 | '' 23 | ]); 24 | $this->setOptions([ 25 | 'l,list' => "List all seeder files only. With this option, seeding does not run.", 26 | ]); 27 | $this->setDescr( 28 | 'Seed the database using Seeder class in "application/database/seeds" folder.' 29 | ); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/UserConfig.php: -------------------------------------------------------------------------------- 1 | 6 | * @license MIT License 7 | * @copyright 2015 Kenji Suzuki 8 | * @link https://github.com/kenjis/codeigniter-cli 9 | */ 10 | 11 | namespace Kenjis\CodeIgniter_Cli; 12 | 13 | use Aura\Di\Container; 14 | 15 | class UserConfig 16 | { 17 | public static function registerCommandClasses(Container $di, $ci, array $paths) 18 | { 19 | foreach ($paths as $path) { 20 | foreach (glob($path . '*Command.php') as $file) { 21 | $classname = static::findClass($di, $file); 22 | if ($classname === '') { 23 | break; 24 | } 25 | 26 | $di->params[$classname] = [ 27 | 'context' => $di->lazyGet('aura/cli-kernel:context'), 28 | 'stdio' => $di->lazyGet('aura/cli-kernel:stdio'), 29 | 'ci' => $ci, 30 | ]; 31 | } 32 | } 33 | } 34 | 35 | /** 36 | * @param string $file 37 | * @return string classname, if not found returns '' 38 | */ 39 | protected static function findClass(Container $di, $file) 40 | { 41 | require_once $file; 42 | $classname = basename($file, '.php'); 43 | if (! class_exists($classname)) { 44 | $stdio = $di->get('aura/cli-kernel:stdio'); 45 | $stdio->errln( 46 | '<>No such class: ' . $classname . ' in ' . $file . '<>' 47 | ); 48 | return ''; 49 | } 50 | return $classname; 51 | } 52 | 53 | public static function registerCommands( 54 | Container $di, $dispatcher, $help_service, array $paths 55 | ) 56 | { 57 | foreach ($paths as $path) { 58 | foreach (glob($path . '*Command.php') as $file) { 59 | $classname = static::findClass($di, $file); 60 | if ($classname === '') { 61 | break; 62 | } 63 | 64 | $command_name = strtolower(basename($classname, 'Command')); 65 | $dispatcher->setObject( 66 | $command_name, 67 | $di->lazyNew($classname) 68 | ); 69 | } 70 | 71 | foreach (glob($path . '*CommandHelp.php') as $file) { 72 | $classname = static::findClass($di, $file); 73 | if ($classname === '') { 74 | break; 75 | } 76 | 77 | $command_name = strtolower(basename($classname, 'CommandHelp')); 78 | $help_service->set( 79 | $command_name, 80 | $di->lazyNew($classname) 81 | ); 82 | } 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /tests/CliTest.php: -------------------------------------------------------------------------------- 1 | assertContains($expect, $actual); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tests/Command/CommandTest.php: -------------------------------------------------------------------------------- 1 | newContext($GLOBALS); 17 | $this->stdio = $cli_factory->newStdio( 18 | 'php://memory', 19 | 'php://memory', 20 | 'php://memory' 21 | ); 22 | $this->stdout = $this->stdio->getStdout(); 23 | $this->stderr = $this->stdio->getStderr(); 24 | $this->cmd = new Test($context, $this->stdio, $ci); 25 | } 26 | 27 | public function test_no_property() 28 | { 29 | $this->setExpectedException('RuntimeException'); 30 | $status = $this->cmd->__invoke(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /tests/Command/GenerateHelpTest.php: -------------------------------------------------------------------------------- 1 | help = new GenerateHelp(new OptionFactory); 12 | } 13 | 14 | public function test_get_help() 15 | { 16 | $actual = $this->help->getSummary('run'); 17 | $expected = 'No such generator class: Kenjis\CodeIgniter_Cli\Command\Generate\Not_exists' . PHP_EOL; 18 | $this->assertEquals('Generate code.', $actual); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /tests/Command/GenerateTest.php: -------------------------------------------------------------------------------- 1 | ci =& get_instance(); 13 | $cli_factory = new CliFactory; 14 | $context = $cli_factory->newContext($GLOBALS); 15 | $this->stdio = $cli_factory->newStdio( 16 | 'php://memory', 17 | 'php://memory', 18 | 'php://memory' 19 | ); 20 | $this->stdout = $this->stdio->getStdout(); 21 | $this->stderr = $this->stdio->getStderr(); 22 | $this->cmd = new Generate($context, $this->stdio, $this->ci); 23 | 24 | $this->migration_path = __DIR__ . '/../Fake/migrations/'; 25 | foreach (glob($this->migration_path . '*_Test_of_generate_migration.php') as $file) { 26 | unlink($file); 27 | } 28 | } 29 | 30 | public function test_no_generator() 31 | { 32 | $status = $this->cmd->__invoke('not_exists'); 33 | $this->assertEquals(Status::FAILURE, $status); 34 | 35 | $this->stderr->rewind(); 36 | $actual = $this->stderr->fread(); 37 | $expected = 'No such generator class: Kenjis\CodeIgniter_Cli\Command\Generate\Not_exists' . PHP_EOL; 38 | $this->assertEquals($expected, $actual); 39 | } 40 | 41 | public function test_migration_no_classname() 42 | { 43 | $status = $this->cmd->__invoke('migration'); 44 | $this->assertEquals(Status::USAGE, $status); 45 | 46 | $this->stderr->rewind(); 47 | $actual = $this->stderr->fread(); 48 | $expected = 'Classname is needed' . PHP_EOL 49 | . ' eg, generate migration CreateUserTable' . PHP_EOL; 50 | $this->assertEquals($expected, $actual); 51 | } 52 | 53 | public function test_migration_generate() 54 | { 55 | $this->ci->config->set_item('migration_path', $this->migration_path); 56 | $status = $this->cmd->__invoke('migration', 'Test_of_generate_migration'); 57 | $this->assertEquals(Status::SUCCESS, $status); 58 | } 59 | 60 | public function test_migration_generate_file_exist() 61 | { 62 | $this->ci->config->set_item('migration_path', $this->migration_path); 63 | $status = $this->cmd->__invoke('migration', 'Test_of_generate_migration'); 64 | $status = $this->cmd->__invoke('migration', 'Test_of_generate_migration'); 65 | $this->stderr->rewind(); 66 | $error = $this->stderr->fread(); 67 | $expected = '_Test_of_generate_migration.php" already exists'; 68 | $this->assertContains($expected, $error); 69 | $this->assertEquals(Status::FAILURE, $status); 70 | } 71 | 72 | public function test_migration_generate_class_exist() 73 | { 74 | $this->ci->config->set_item('migration_path', $this->migration_path); 75 | $status = $this->cmd->__invoke('migration', 'Test_of_generate_migration'); 76 | 77 | // sleep not to generate the same file name 78 | sleep(1); 79 | $status = $this->cmd->__invoke('migration', 'Test_of_generate_migration'); 80 | $this->stderr->rewind(); 81 | $error = $this->stderr->fread(); 82 | $expected = 'The Class "Test_of_generate_migration" already exists' . PHP_EOL; 83 | $this->assertEquals($expected, $error); 84 | $this->assertEquals(Status::FAILURE, $status); 85 | } 86 | 87 | public function test_migration_generate_class_exist_with_diff_case() 88 | { 89 | $this->ci->config->set_item('migration_path', $this->migration_path); 90 | $status = $this->cmd->__invoke('migration', 'Test_of_generate_migration'); 91 | 92 | // sleep not to generate the same file name 93 | sleep(1); 94 | $status = $this->cmd->__invoke('migration', 'Test_of_Generate_Migration'); 95 | $this->stderr->rewind(); 96 | $error = $this->stderr->fread(); 97 | $expected = 'The Class "Test_of_generate_migration" already exists' . PHP_EOL; 98 | $this->assertEquals($expected, $error); 99 | $this->assertEquals(Status::FAILURE, $status); 100 | } 101 | 102 | public function test_migration_generate_sequential() 103 | { 104 | $this->ci->config->set_item('migration_path', $this->migration_path); 105 | $this->ci->config->set_item('migration_type', 'sequential'); 106 | $status = $this->cmd->__invoke('migration', 'Test_of_generate_migration'); 107 | $this->assertEquals(Status::SUCCESS, $status); 108 | 109 | foreach (glob($this->migration_path . '*_Test_of_generate_migration.php') as $file) { 110 | $this->assertContains('003_Test_of_generate_migration', $file); 111 | unlink($file); 112 | } 113 | } 114 | 115 | public function test_migration_cannot_write_to_file() 116 | { 117 | $migration_path = __DIR__ . '/../Fake/migrations/not-exist-dir/'; 118 | $this->ci->config->set_item('migration_path', $migration_path); 119 | $status = $this->cmd->__invoke('migration', 'Test_of_generate_migration'); 120 | $this->assertEquals(Status::FAILURE, $status); 121 | 122 | $this->stderr->rewind(); 123 | $actual = $this->stderr->fread(); 124 | $this->assertContains("Can't write to ", $actual); 125 | $this->assertContains('Fake/migrations/not-exist-dir/', $actual); 126 | $this->assertContains('Test_of_generate_migration.php', $actual); 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /tests/Command/MigrateHelpTest.php: -------------------------------------------------------------------------------- 1 | help = new MigrateHelp(new OptionFactory); 12 | } 13 | 14 | public function test_get_help() 15 | { 16 | $actual = $this->help->getSummary('run'); 17 | $expected = 'No such generator class: Kenjis\CodeIgniter_Cli\Command\Generate\Not_exists' . PHP_EOL; 18 | $this->assertEquals('Runs the migrations.', $actual); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /tests/Command/MigrateTest.php: -------------------------------------------------------------------------------- 1 | dbforge->drop_table('bbs', true); 14 | $ci->dbforge->drop_table('captcha', true); 15 | $ci->dbforge->drop_table('category', true); 16 | $ci->dbforge->drop_table('product', true); 17 | } 18 | 19 | public function setUp() 20 | { 21 | $this->ci =& get_instance(); 22 | $cli_factory = new CliFactory; 23 | $context = $cli_factory->newContext($GLOBALS); 24 | $this->stdio = $cli_factory->newStdio( 25 | 'php://memory', 26 | 'php://memory', 27 | 'php://memory' 28 | ); 29 | $this->stdout = $this->stdio->getStdout(); 30 | $this->stderr = $this->stdio->getStderr(); 31 | $this->cmd = new Migrate($context, $this->stdio, $this->ci); 32 | $this->ci->config->set_item('migration_version', 20150429110003); 33 | } 34 | 35 | public function test_command_not_exists() 36 | { 37 | $status = $this->cmd->__invoke('command-not-exists'); 38 | $this->assertEquals(Status::USAGE, $status); 39 | 40 | $this->stderr->rewind(); 41 | $actual = $this->stderr->fread(); 42 | $expected = 'No such command: command-not-exists' . PHP_EOL; 43 | $this->assertEquals($expected, $actual); 44 | } 45 | 46 | public function test_migrate() 47 | { 48 | $status = $this->cmd->__invoke(); 49 | $this->assertEquals(Status::SUCCESS, $status); 50 | } 51 | 52 | public function test_migrate_to_version_not_exists() 53 | { 54 | $status = $this->cmd->__invoke('19990101120000'); 55 | $this->assertEquals(Status::FAILURE, $status); 56 | } 57 | 58 | public function test_migrate_to_specific_version() 59 | { 60 | $status = $this->cmd->__invoke('20150429110003'); 61 | $this->assertEquals(Status::SUCCESS, $status); 62 | } 63 | 64 | public function test_status() 65 | { 66 | $status = $this->cmd->__invoke('status'); 67 | $this->assertEquals(Status::SUCCESS, $status); 68 | 69 | $this->stdout->rewind(); 70 | $actual = $this->stdout->fread(); 71 | $this->assertContains('20150429090001_Create_bbs.php', $actual); 72 | $this->assertContains('20150429110003_Create_category.php (current/database)', $actual); 73 | } 74 | 75 | public function test_status_current_not_equals_database() 76 | { 77 | $this->ci->config->set_item('migration_version', 20150429120004); 78 | $status = $this->cmd->__invoke('status'); 79 | $this->assertEquals(Status::SUCCESS, $status); 80 | 81 | $this->stdout->rewind(); 82 | $actual = $this->stdout->fread(); 83 | $this->assertContains('20150429110003_Create_category.php (database)', $actual); 84 | $this->assertContains('20150429120004_Create_product.php (current)', $actual); 85 | } 86 | 87 | public function test_version() 88 | { 89 | $status = $this->cmd->__invoke('version'); 90 | $this->assertEquals(Status::SUCCESS, $status); 91 | 92 | $this->stdout->rewind(); 93 | $actual = $this->stdout->fread(); 94 | $this->assertContains(' current: 20150429110003 (in config/migration.php)', $actual); 95 | $this->assertContains('database: 20150429110003 (in database table)', $actual); 96 | $this->assertContains(' latest: 20150429120004 (in migration files)', $actual); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /tests/Command/RunHelpTest.php: -------------------------------------------------------------------------------- 1 | help = new RunHelp(new OptionFactory); 12 | } 13 | 14 | public function test_get_help() 15 | { 16 | $actual = $this->help->getSummary('run'); 17 | $expected = 'No such generator class: Kenjis\CodeIgniter_Cli\Command\Generate\Not_exists' . PHP_EOL; 18 | $this->assertEquals('Run controller.', $actual); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /tests/Command/RunTest.php: -------------------------------------------------------------------------------- 1 | newContext($GLOBALS); 15 | $this->stdio = $cli_factory->newStdio( 16 | 'php://memory', 17 | 'php://memory', 18 | 'php://memory' 19 | ); 20 | $this->stdout = $this->stdio->getStdout(); 21 | $this->stderr = $this->stdio->getStderr(); 22 | $this->cmd = new Run($context, $this->stdio, $ci); 23 | } 24 | 25 | public function test_run_no_controller() 26 | { 27 | $status = $this->cmd->__invoke(); 28 | $this->assertEquals(Status::USAGE, $status); 29 | 30 | $this->stderr->rewind(); 31 | $actual = $this->stderr->fread(); 32 | $expected = 'Controller is needed' . PHP_EOL; 33 | $this->assertEquals($expected, $actual); 34 | } 35 | 36 | public function test_run_welcome() 37 | { 38 | ob_start(); 39 | $status = $this->cmd->__invoke('welcome'); 40 | ob_end_clean(); 41 | $this->assertEquals(Status::SUCCESS, $status); 42 | 43 | $this->stdout->rewind(); 44 | $actual = $this->stdout->fread(); 45 | $expected = 'php public/index.php welcome'; 46 | $this->assertContains($expected, $actual); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /tests/Command/SeedHelpTest.php: -------------------------------------------------------------------------------- 1 | help = new SeedHelp(new OptionFactory); 12 | } 13 | 14 | public function test_get_help() 15 | { 16 | $actual = $this->help->getSummary('run'); 17 | $expected = 'No such generator class: Kenjis\CodeIgniter_Cli\Command\Generate\Not_exists' . PHP_EOL; 18 | $this->assertEquals('Seed the database with records.', $actual); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /tests/Command/SeedTest.php: -------------------------------------------------------------------------------- 1 | seeder_path = ROOTPATH . '/vendor/kenjis/codeigniter-cli/tests/Fake/seeds/'; 13 | 14 | $ci =& get_instance(); 15 | $cli_factory = new CliFactory; 16 | $context = $cli_factory->newContext($GLOBALS); 17 | $this->stdio = $cli_factory->newStdio( 18 | 'php://memory', 19 | 'php://memory', 20 | 'php://memory' 21 | ); 22 | $this->stdout = $this->stdio->getStdout(); 23 | $this->stderr = $this->stdio->getStderr(); 24 | $this->cmd = new Seed($context, $this->stdio, $ci); 25 | $this->cmd->setSeederPath($this->seeder_path); 26 | } 27 | 28 | public function test_seed() 29 | { 30 | $this->expectOutputString('Table1SeederTable2SeederTable1Seeder'); 31 | $status = $this->cmd->__invoke(); 32 | $this->assertEquals(Status::SUCCESS, $status); 33 | 34 | $this->stdout->rewind(); 35 | $actual = $this->stdout->fread(); 36 | $expected = 'Seeded: Table1Seeder' . PHP_EOL 37 | . 'Seeded: Table2Seeder' . PHP_EOL 38 | . 'Seeded: Table1Seeder' . PHP_EOL 39 | . 'Seeded: Table3Seeder' . PHP_EOL; 40 | $this->assertEquals($expected, $actual); 41 | } 42 | 43 | public function test_seed_specific_class() 44 | { 45 | $this->expectOutputString('Table1Seeder'); 46 | $status = $this->cmd->__invoke('Table1Seeder'); 47 | $this->assertEquals(Status::SUCCESS, $status); 48 | 49 | $this->stdout->rewind(); 50 | $actual = $this->stdout->fread(); 51 | $expected = 'Seeded: Table1Seeder' . PHP_EOL; 52 | $this->assertEquals($expected, $actual); 53 | } 54 | 55 | public function test_seed_list() 56 | { 57 | $GLOBALS['argv'][1] = 'seed'; 58 | $GLOBALS['argv'][2] = '-l'; 59 | $GLOBALS['argc'] = 3; 60 | 61 | $ci =& get_instance(); 62 | $cli_factory = new CliFactory; 63 | $context = $cli_factory->newContext($GLOBALS); 64 | $this->cmd = new Seed($context, $this->stdio, $ci); 65 | $this->cmd->setSeederPath($this->seeder_path); 66 | 67 | $status = $this->cmd->__invoke(); 68 | $this->assertEquals(Status::SUCCESS, $status); 69 | 70 | $this->stdout->rewind(); 71 | $actual = $this->stdout->fread(); 72 | $this->assertContains('Table1Seeder', $actual); 73 | $this->assertContains('Table2Seeder', $actual); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /tests/Fake/Command/Test.php: -------------------------------------------------------------------------------- 1 | 6 | * @license MIT License 7 | * @copyright 2015 Kenji Suzuki 8 | * @link https://github.com/kenjis/codeigniter-cli 9 | */ 10 | 11 | namespace Kenjis\CodeIgniter_Cli\Command; 12 | 13 | use Aura\Cli\Status; 14 | 15 | class Test extends Command 16 | { 17 | public function __invoke() 18 | { 19 | $this->not_exsits; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tests/Fake/migrations/001_Create_bbs.php: -------------------------------------------------------------------------------- 1 | 7 | * Created on: 2015/04/29 08:10:27 8 | */ 9 | class Migration_Create_bbs extends CI_Migration { 10 | 11 | public function up() { 12 | $this->dbforge->add_field([ 13 | 'id' => [ 14 | 'type' => 'INT', 15 | 'constraint' => 11, 16 | 'auto_increment' => TRUE 17 | ], 18 | 'name' => [ 19 | 'type' => 'VARCHAR', 20 | 'constraint' => '64', 21 | ], 22 | 'email' => [ 23 | 'type' => 'VARCHAR', 24 | 'constraint' => '64', 25 | 'null' => TRUE, 26 | ], 27 | 'subject' => [ 28 | 'type' => 'VARCHAR', 29 | 'constraint' => '128', 30 | 'null' => TRUE, 31 | ], 32 | 'body' => [ 33 | 'type' => 'TEXT', 34 | 'null' => TRUE, 35 | ], 36 | 'password' => [ 37 | 'type' => 'VARCHAR', 38 | 'constraint' => '32', 39 | 'null' => TRUE, 40 | ], 41 | 'ip_address' => [ 42 | 'type' => 'VARCHAR', 43 | 'constraint' => '39', 44 | 'null' => TRUE, 45 | ], 46 | ]); 47 | 48 | $this->dbforge->add_key('id', TRUE); 49 | $this->dbforge->create_table('bbs'); 50 | } 51 | 52 | public function down() { 53 | $this->dbforge->drop_table('bbs'); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /tests/Fake/migrations/002_Create_captcha.php: -------------------------------------------------------------------------------- 1 | 7 | * Created on: 2015/04/29 10:38:53 8 | */ 9 | class Migration_Create_captcha extends CI_Migration { 10 | 11 | public function up() { 12 | $this->dbforge->add_field([ 13 | 'captcha_id' => [ 14 | 'type' => 'BIGINT', 15 | 'constraint' => 13, 16 | 'unsigned' => TRUE, 17 | 'auto_increment' => TRUE 18 | ], 19 | 'captcha_time' => [ 20 | 'type' => 'INT', 21 | 'constraint' => 10, 22 | 'unsigned' => TRUE, 23 | ], 24 | 'word' => [ 25 | 'type' => 'VARCHAR', 26 | 'constraint' => '20', 27 | ], 28 | ]); 29 | $this->dbforge->add_key('captcha_id', TRUE); 30 | $this->dbforge->add_key('word'); 31 | $this->dbforge->create_table('captcha'); 32 | } 33 | 34 | public function down() { 35 | $this->dbforge->drop_table('captcha'); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /tests/Fake/migrations/20150429090001_Create_bbs.php: -------------------------------------------------------------------------------- 1 | 7 | * Created on: 2015/04/29 08:10:27 8 | */ 9 | class Migration_Create_bbs extends CI_Migration { 10 | 11 | public function up() { 12 | $this->dbforge->add_field([ 13 | 'id' => [ 14 | 'type' => 'INT', 15 | 'constraint' => 11, 16 | 'auto_increment' => TRUE 17 | ], 18 | 'name' => [ 19 | 'type' => 'VARCHAR', 20 | 'constraint' => '64', 21 | ], 22 | 'email' => [ 23 | 'type' => 'VARCHAR', 24 | 'constraint' => '64', 25 | 'null' => TRUE, 26 | ], 27 | 'subject' => [ 28 | 'type' => 'VARCHAR', 29 | 'constraint' => '128', 30 | 'null' => TRUE, 31 | ], 32 | 'body' => [ 33 | 'type' => 'TEXT', 34 | 'null' => TRUE, 35 | ], 36 | 'password' => [ 37 | 'type' => 'VARCHAR', 38 | 'constraint' => '32', 39 | 'null' => TRUE, 40 | ], 41 | 'ip_address' => [ 42 | 'type' => 'VARCHAR', 43 | 'constraint' => '39', 44 | 'null' => TRUE, 45 | ], 46 | ]); 47 | 48 | $this->dbforge->add_key('id', TRUE); 49 | $this->dbforge->create_table('bbs'); 50 | } 51 | 52 | public function down() { 53 | $this->dbforge->drop_table('bbs'); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /tests/Fake/migrations/20150429100002_Create_captcha.php: -------------------------------------------------------------------------------- 1 | 7 | * Created on: 2015/04/29 10:38:53 8 | */ 9 | class Migration_Create_captcha extends CI_Migration { 10 | 11 | public function up() { 12 | $this->dbforge->add_field([ 13 | 'captcha_id' => [ 14 | 'type' => 'BIGINT', 15 | 'constraint' => 13, 16 | 'unsigned' => TRUE, 17 | 'auto_increment' => TRUE 18 | ], 19 | 'captcha_time' => [ 20 | 'type' => 'INT', 21 | 'constraint' => 10, 22 | 'unsigned' => TRUE, 23 | ], 24 | 'word' => [ 25 | 'type' => 'VARCHAR', 26 | 'constraint' => '20', 27 | ], 28 | ]); 29 | $this->dbforge->add_key('captcha_id', TRUE); 30 | $this->dbforge->add_key('word'); 31 | $this->dbforge->create_table('captcha'); 32 | } 33 | 34 | public function down() { 35 | $this->dbforge->drop_table('captcha'); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /tests/Fake/migrations/20150429110003_Create_category.php: -------------------------------------------------------------------------------- 1 | 7 | * Created on: 2015/04/29 10:46:11 8 | */ 9 | class Migration_Create_category extends CI_Migration { 10 | 11 | public function up() { 12 | $this->dbforge->add_field([ 13 | 'id' => [ 14 | 'type' => 'INT', 15 | 'constraint' => 11, 16 | 'auto_increment' => TRUE 17 | ], 18 | 'name' => [ 19 | 'type' => 'VARCHAR', 20 | 'constraint' => 64, 21 | ], 22 | ]); 23 | $this->dbforge->add_key('id', TRUE); 24 | $this->dbforge->create_table('category'); 25 | 26 | $this->db->insert('category', ['name' => 'Book']); 27 | $this->db->insert('category', ['name' => 'CD']); 28 | $this->db->insert('category', ['name' => 'DVD']); 29 | } 30 | 31 | public function down() { 32 | $this->dbforge->drop_table('category'); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /tests/Fake/migrations/20150429120004_Create_product.php: -------------------------------------------------------------------------------- 1 | 7 | * Created on: 2015/04/29 11:38:36 8 | */ 9 | class Migration_Create_product extends CI_Migration { 10 | 11 | public function up() { 12 | $this->dbforge->add_field([ 13 | 'id' => [ 14 | 'type' => 'INT', 15 | 'constraint' => 11, 16 | 'auto_increment' => TRUE 17 | ], 18 | 'category_id' => [ 19 | 'type' => 'INT', 20 | 'constraint' => 11, 21 | 'null' => TRUE, 22 | ], 23 | 'name' => [ 24 | 'type' => 'VARCHAR', 25 | 'constraint' => 64, 26 | ], 27 | 'detail' => [ 28 | 'type' => 'TEXT', 29 | 'null' => TRUE, 30 | ], 31 | 'price' => [ 32 | 'type' => 'INT', 33 | 'constraint' => 11, 34 | ], 35 | 'img' => [ 36 | 'type' => 'VARCHAR', 37 | 'constraint' => 64, 38 | 'null' => TRUE, 39 | ], 40 | ]); 41 | $this->dbforge->add_key('id', TRUE); 42 | $this->dbforge->create_table('product'); 43 | } 44 | 45 | public function down() { 46 | $this->dbforge->drop_table('product'); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /tests/Fake/seeds/Table1Seeder.php: -------------------------------------------------------------------------------- 1 | call('Table1Seeder'); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /tests/Fake/user_commands/TestCommand.php: -------------------------------------------------------------------------------- 1 | xxx; 8 | $this->stdio->outln('<>This is TestCommand class<>'); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /tests/Fake/user_commands/TestCommandHelp.php: -------------------------------------------------------------------------------- 1 | setSummary('A single-line summary.'); 8 | $this->setUsage(' '); 9 | $this->setOptions([ 10 | 'f,foo' => "The -f/--foo option description", 11 | 'bar::' => "The --bar option description", 12 | ]); 13 | $this->setDescr("A multi-line description of the command."); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /tests/Fake/user_commands_bad/BadCommand.php: -------------------------------------------------------------------------------- 1 | stdio->outln('<>This is WrongCommand class<>'); 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /tests/UserConfigTest.php: -------------------------------------------------------------------------------- 1 | di = new Container(new Factory); 13 | $this->di->set('aura/cli-kernel:stdio', $this->di->lazyNew('Aura\Cli\Stdio')); 14 | $this->di->params['Aura\Cli\Stdio'] = [ 15 | 'stdin' => $this->di->lazyNew('Aura\Cli\Stdio\Handle', [ 16 | 'name' => 'php://memory', 17 | 'mode' => 'r', 18 | ]), 19 | 'stdout' => $this->di->lazyNew('Aura\Cli\Stdio\Handle', [ 20 | 'name' => 'php://memory', 21 | 'mode' => 'w+', 22 | ]), 23 | 'stderr' => $this->di->lazyNew('Aura\Cli\Stdio\Handle', [ 24 | 'name' => 'php://memory', 25 | 'mode' => 'w+', 26 | ]), 27 | 'formatter' => $this->di->lazyNew('Aura\Cli\Stdio\Formatter'), 28 | ]; 29 | } 30 | 31 | public function test_registerCommandClasses() 32 | { 33 | $ci = new \stdClass(); 34 | $paths = [ __DIR__ . '/Fake/user_commands/' ]; 35 | UserConfig::registerCommandClasses($this->di, $ci, $paths); 36 | 37 | $this->assertTrue(array_key_exists('TestCommand', $this->di->params)); 38 | } 39 | 40 | public function test_registerCommandClasses_bad_classname() 41 | { 42 | $ci = new \stdClass(); 43 | $paths = [ __DIR__ . '/Fake/user_commands_bad/' ]; 44 | UserConfig::registerCommandClasses($this->di, $ci, $paths); 45 | 46 | $stderr = $this->di->get('aura/cli-kernel:stdio')->getStderr(); 47 | $stderr->rewind(); 48 | $actual = $stderr->fread(); 49 | $expected = 'No such class: BadCommand'; 50 | $this->assertContains($expected, $actual); 51 | } 52 | 53 | public function test_registerCommands() 54 | { 55 | $this->di->set( 56 | 'aura/cli-kernel:dispatcher', 57 | $this->di->lazyNew('Aura\Dispatcher\Dispatcher', [ 58 | 'object_param' => 'command', 59 | ] 60 | )); 61 | $dispatcher = $this->di->get('aura/cli-kernel:dispatcher'); 62 | $this->di->set( 63 | 'aura/cli-kernel:help_service', 64 | $this->di->lazyNew('Aura\Cli_Kernel\HelpService') 65 | ); 66 | $help_service = $this->di->get('aura/cli-kernel:help_service'); 67 | $paths = [ __DIR__ . '/Fake/user_commands/' ]; 68 | UserConfig::registerCommands($this->di, $dispatcher, $help_service, $paths); 69 | 70 | $this->assertTrue($dispatcher->hasObject('test')); 71 | $this->assertTrue($help_service->has('test')); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /tests/data/sqlite-database.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kenjis/codeigniter-cli/7c4990eae6a59be26e819841b2853d11fc927fad/tests/data/sqlite-database.db -------------------------------------------------------------------------------- /tmp/.placeholder: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kenjis/codeigniter-cli/7c4990eae6a59be26e819841b2853d11fc927fad/tmp/.placeholder --------------------------------------------------------------------------------