PHPackages                             aura/cli-project - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. aura/cli-project

ActiveProject[Framework](/categories/framework)

aura/cli-project
================

A minimal command-line framework built from Aura v2 packages

2.0.2(11y ago)134992BSD-2-ClausePHP

Since Apr 14Pushed 11y ago7 watchersCompare

[ Source](https://github.com/auraphp/Aura.Cli_Project)[ Packagist](https://packagist.org/packages/aura/cli-project)[ RSS](/packages/aura-cli-project/feed)WikiDiscussions master Synced 5d ago

READMEChangelog (4)Dependencies (2)Versions (5)Used By (0)

Aura.Cli\_Project
=================

[](#auracli_project)

This package provides a minimal framework for command-line projects.

By "minimal" we mean *very* minimal. The package provides only a dependency injection container, a configuration system, a dispatcher, a pair of context and standard I/O objects, and a logging instance.

This minimal implementation should not be taken as "restrictive". The DI container, with its two-stage configuration system, allows a wide range of programmatic service definitions. The dispatcher is built with iterative refactoring in mind, so you can start with micro-framework-like closure commands, and work your way up to more complex command objects of your own design.

Foreword
--------

[](#foreword)

### Requirements

[](#requirements)

This project requires PHP 5.4 or later; we recommend using the latest available version of PHP as a matter of principle.

Unlike Aura library packages, this project package has userland dependencies, which themselves may have other dependencies:

- [aura/cli-kernel](https://packagist.org/packages/aura/cli-kernel)
- [monolog/monolog](https://packagist.org/packages/monolog/monolog)

### Installation

[](#installation)

Install this project via Composer to a `{$PROJECT_PATH}` of your choosing:

```
composer create-project aura/cli-project {$PROJECT_PATH}

```

This will create the project skeleton and install all of the necessary packages.

### Tests

[](#tests)

[![Build Status](https://camo.githubusercontent.com/bf891ed34f3e1978ea539ebf55c68c088f88a957b9a670e1624dc3cd455acb59/68747470733a2f2f7472617669732d63692e6f72672f617572617068702f417572612e436c695f50726f6a6563742e706e67)](https://travis-ci.org/auraphp/Aura.Cli_Project)

To run the unit tests at the command line, issue `phpunit` at the package root. This requires [PHPUnit](http://phpunit.de/) to be available as `phpunit`.

Alternatively, after you have installed the project, go to the project directory and issue the following command:

```
cd {$PROJECT_PATH}
php cli/console.php hello

```

You should see the output `Hello World!`. Try passing a name after `hello` to see `Hello name!`.

### PSR Compliance

[](#psr-compliance)

This projects attempts to comply with [PSR-1](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md), [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md), and [PSR-4](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader.md). If you notice compliance oversights, please send a patch via pull request.

### Community

[](#community)

To ask questions, provide feedback, or otherwise communicate with the Aura community, please join our [Google Group](http://groups.google.com/group/auraphp), follow [@auraphp on Twitter](http://twitter.com/auraphp), or chat with us on #auraphp on Freenode.

### Services

[](#services)

This package uses services defined by:

- [Aura.Project\_Kernel](https://github.com/auraphp/Aura.Project_Kernel#services)
- [Aura.Cli\_Kernel](https://github.com/auraphp/Aura.Cli_Kernel#services)

This project resets the following services:

- `aura/project-kernel:logger`: an instance of `Monolog\Logger`

Getting Started
---------------

[](#getting-started)

### Component Packages

[](#component-packages)

This project combines a collection of independent Aura packages into a cohesive whole. The operation of each package is documented separately.

The dependency injection *Container* is absolutely central to the operation of an Aura project. Please be familiar with [the Aura.Di docs](https://github.com/auraphp/Aura.Di) before continuing.

You should also familiarize yourself with [Aura.Dispatcher](https://github.com/auraphp/Aura.Dispatcher), as well as the [Aura.Cli](https://github.com/auraphp/Aura.Cli) *Context*, *Stdio*, and *Status* objects.

### Project Configuration

[](#project-configuration)

Every Aura project is configured the same way. Please see the [shared configuration docs](https://github.com/auraphp/Aura.Project_Kernel#configuration) for more information.

### Logging

[](#logging)

The project automatically logs to `{$PROJECT_PATH}/tmp/log/{$mode}.log`. If you want to change the logging behaviors for a particular config mode, edit the related config file (e.g., `config/Dev.php`) file to modify the `aura/project-kernel:logger` service.

### Commands

[](#commands)

We configure commands via the project-level `config/` class files. If a command needs to be available in every config mode, edit the project-level `config/Common.php` class file. If it only needs to be available in a specific mode, e.g. `dev`, then edit the config file for that mode.

Here are two different styles of command definition.

#### Micro-Framework Style

[](#micro-framework-style)

The following is an example of a command where the logic is embedded in the dispatcher, using the `aura/cli-kernel:context` and `aura/cli-kernel:stdio` services along with standard exit codes. (The dispatcher object name doubles as the command name.)

```
