PHPackages                             cspray/annotated-console - 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. [CLI &amp; Console](/categories/cli)
4. /
5. cspray/annotated-console

ActiveLibrary[CLI &amp; Console](/categories/cli)

cspray/annotated-console
========================

An abstraction layer over Symfony Console to easily use Annotated Container in your CLI apps.

016[1 PRs](https://github.com/cspray/annotated-console/pulls)PHPCI passing

Since Sep 8Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/cspray/annotated-console)[ Packagist](https://packagist.org/packages/cspray/annotated-console)[ RSS](/packages/cspray-annotated-console/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (3)Used By (0)

Annotated Console
=================

[](#annotated-console)

Annotated Console is a way to autowire and configure [symfony/console](https://github.com/symfony/console) applications using [Annotated Container](https://github.com/cspray/annotated-container). Out of the box, Annotated Console is intended to provide the following features:

- Automatically add Command instances to a Symfony Application.
- Allow configuring a Command using PHP 8 Attributes.
- Depend on services in Command constructors and take advantage of other functionality provided by [Annotated Container](https://github.com/cspray/annotated-container).

Installation
------------

[](#installation)

I recommend installing Annotated Console using [Composer](https://getcomposer.org).

```
composer require cspray/annotated-console:dev-main cspray/annotated-container:v2.x-dev
```

> Annotated Console currently requires Annotated Container v2.x-dev. When Annotated Container releases 2.0 this library will release a 1.0 package.

Quick Start
-----------

[](#quick-start)

Annotated Console is designed to get going in a few straightforward steps.

Step 1 - Initiate your Container
--------------------------------

[](#step-1---initiate-your-container)

The functionality for this library is primarily provided by [Annotated Container](https://github.com/cspray/annotated-container). Which means you need to make sure that your configuration is setup to boostrap your app. As long as you have a PSR-4 or PSR-0 autoload configuration setup in your `composer.json` you can run the following command from the root of your project:

```
./vendor/bin/annotated-container init
```

By default, the init command will create a directory to cache your Container so static analysis doesn't have to run on every Command. Early in development it is advised to disable the cache by removing the `` element from the configuration file. It is important that if new Services or Commands are added the Container cache is busted appropriately.

Step 2 - Create your App's Binary
---------------------------------

[](#step-2---create-your-apps-binary)

Next, you'll need to create the file that you'll use to run your app. You can name and store this file anywhere you'd like, but we'll put our example in `./bin/acme`.

```
#!/usr/bin/env php
