PHPackages                             cocur/pli - 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. cocur/pli

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

cocur/pli
=========

Pli is a library and set of conventions to bootstrap Console applications with Symfony Console, DependencyInjection and Config components.

v0.1.2(10y ago)343MITPHP

Since May 18Pushed 3y ago2 watchersCompare

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

READMEChangelog (3)Dependencies (8)Versions (5)Used By (0)

Pli
===

[](#pli)

> Pli is a library and set of conventions to bootstrap Console applications with Symfony [Console](https://github.com/symfony/Console), [DependencyInjection](https://github.com/symfony/DependencyInjection)and [Config](https://github.com/symfony/Config) components.

[![Latest Version](https://camo.githubusercontent.com/e7753e0c80f16faf08488efc6a1764c0f18df87f93cf1f81d62e0336c4c12e11/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636f6375722f706c692e737667)](https://packagist.org/packages/cocur/pli)[![Build Status](https://camo.githubusercontent.com/eb135849c5237ac1baa48085653fd1836e6ac0f21cd3d596888ef8d6868fa3d6/68747470733a2f2f7472617669732d63692e6f72672f636f6375722f706c692e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/cocur/pli)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/0d832f9d10b7e7cd14b8a8d2ed33692d1b1f507fc8997c65098a8ce8860a2c62/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f636f6375722f706c692f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/cocur/pli/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/63640a751b58d4bf373bb0ffc5d79f6ab802d6807637306bedfe3a2e3df9aac0/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f636f6375722f706c692f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/cocur/pli/?branch=master)

The Symfony components are incredible powerful, but the price for this flexibility is quite a bit of bootstrapping code to set the components up. Especially when integrating Console, DependencyInjection and Config a developer has to copy and adapt a lot of code from the docs. **Pli** uses some assumptions (such as config files in Yaml format) to reduce the amount of code required to bootstrap a simple console application.

Developed by [Florian Eckerstorfer](https://florian.ec) in Vienna, Europe.

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

[](#installation)

You can install Pli using [Composer](http://getcomposer.org).

```
$ composer require cocur/pli
```

Usage
-----

[](#usage)

Bootstrapping a console application with Pli is a three-step process.

1. **Load configuration:** Load and parse one or more Yaml config files.
2. **Build container:** Create a container and invokes the *extension* to initialize it
3. **Create application:** Creates and application and adds all command tagged with `command` to it. If a command implements `ContainerAwareInterface` the container is set on the command.

First we need our main file with the initialization of `Pli`. You also need a configuration and a extension class and Pli is very similar to Symfony in this regard. However, the Pli-version of an extension has far less features.

```
// console.php

use Cocur\Pli\Pli;

$pli = new Pli(__DIR__.'/config');
$config = $pli->loadConfiguration(new AcmeConfiguration(), ['config.yml']);
$container = $pli->buildContainer(new AcmeExtension(), $config);
$application = $pli->getApplication($container);
$application->run();
```

```
// src/AcmeConfiguration.php
