1.9.0 2016-10-14 07:42 UTC


A Simple PHP CLI Framework provides


Add in2pire/cli to your composer.json and run composer install


  • Application
  • Command
  • Task



  • APP_NAME: Your app name
  • APP_PATH: Path to your cli application
  • APP_CONF_PATH: Path to directory that stores config files for your application

How to build your cli application

  1. Create project with composer and prepare all the information (or add in2pire/cli to your composer.json)
  2. Prepare config directory and config files. The directory must be inside the project.
  3. Create your cli application. Define needed constants
  4. Add command and task

For examples

#!/usr/bin/env php

 * Memcached CLI Application

if (PHP_SAPI !== 'cli') {
    echo 'Warning: memcached-cli should be invoked via the CLI version of PHP, not the ' . PHP_SAPI . ' SAPI' . PHP_EOL;

define('APP_NAME', 'memcached-cli');
define('APP_PATH', __DIR__);
define('APP_CONF_PATH', APP_PATH . '/../conf/' . APP_NAME);

// Add class loader.
require APP_PATH . '/../vendor/autoload.php';

// Run application.
$app = new In2pire\Cli\CliApplication();

How to compile your cli application

The compiler is distributed in installation directory of in2pire/cli. It uses Phar to put entire application into a single file for easy distribution and installation


  • --config: The path to config directory of your cli application
  • --bin: The path to main executable of your cli application
  • --no-compress: Do not compress php files
  • --no-optimize: Do not optimize class loaders
  • --no-phar: Do not add .phar extension
  • --executable: Create executable file


  • You need to run compiler in your git repository. It helps to detect application version
  • You need Phar in order to compile your application
  • zlib or bzip2 is required if you want to reduce size of your binary file

For example, in memcached-cli. The binary is compiled by running

./bin/compile --bin=bin/memcached-cli --config=conf/memcached-cli --executable --no-phar



  • PHP >= 5.4
  • Symfony YAML (symfony/yaml) >= 2.6
  • Symfony Console (symfony/console) >= 2.6
  • IN2PIRE Utilities (in2pire/utility) stable version}


  • Better documentation
  • Official website
  • Generator that helps to create class and config files
  • Improve compiler to detect config directory