PHPackages                             rougin/blueprint - 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. rougin/blueprint

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

rougin/blueprint
================

A bootstrap for PHP console projects.

v0.7.1(1mo ago)38.0k3MITPHPPHP &gt;=5.3.0CI passing

Since Aug 9Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/rougin/blueprint)[ Packagist](https://packagist.org/packages/rougin/blueprint)[ Docs](https://roug.in/blueprint/)[ RSS](/packages/rougin-blueprint/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (10)Versions (15)Used By (3)

Blueprint
=========

[](#blueprint)

[![Latest Version on Packagist](https://camo.githubusercontent.com/df4550dd34f2942b86a847bbce8838c24a9e971d83f661a6760d85a0c96f01bd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f726f7567696e2f626c75657072696e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rougin/blueprint)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/rougin/blueprint/blob/master/LICENSE.md)[![Build Status](https://camo.githubusercontent.com/67820dd5372ca48304ccedaa55b742fd7da0af66aa5fd78fe3b2484f9fec578c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f726f7567696e2f626c75657072696e742f6275696c642e796d6c3f7374796c653d666c61742d737175617265)](https://github.com/rougin/blueprint/actions)[![Coverage Status](https://camo.githubusercontent.com/4b68f90209552ca3f31192a3c46562be35526558db1a0143b421e8eba5fd8b1c/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f726f7567696e2f626c75657072696e743f7374796c653d666c61742d737175617265)](https://app.codecov.io/gh/rougin/blueprint)[![Total Downloads](https://camo.githubusercontent.com/4a570f6051f789a791e76239310944b54332a4295bd2ee60d28e018bf1c46899/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f726f7567696e2f626c75657072696e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rougin/blueprint)

Blueprint is a PHP package for bootstrapping console applications.

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

[](#installation)

Install `Blueprint` via [Composer](https://getcomposer.org/):

```
$ composer require rougin/blueprint
```

Basic usage
-----------

[](#basic-usage)

Create a `blueprint.php` file using the `initialize` command:

```
$ vendor/bin/blueprint initialize
```

```
// blueprint.php

$file = array();

// Details for the console app ---
$file['name'] = 'Blueprint';

$file['version'] = '0.7.1';
// -------------------------------

// Path for the commands and templates ----
$paths = array();

$root = '%%CURRENT_DIRECTORY%%';

$paths['templates'] = $root . '/Templates';

$paths['commands'] = $root . '/Commands';

$file['paths'] = $paths;
// ----------------------------------------

// Namespace for the commands ----------
$namespace = 'Acme\Commands';

$data = array('commands' => $namespace);

$file['namespaces'] = $data;
// -------------------------------------

return $file;
```

Note

- Replace the values specified in the `blueprint.php` file.
- Add commands and templates (if applicable) to their respective directories.
- A `blueprint.yml` file is also supported (use `--format=yml`).

Before writing a command, the `commands` property in `blueprint.php` must be updated first:

```
 // blueprint.php

 // ...

-$namespace = 'Acme\Commands';
+$namespace = 'Rrsg\Commands';
```

Then create the command (e.g., `TestCommand`) to its assigned directory (e.g., `src/Commands`):

```
// src/Commands/TestCommand.php

namespace Rrsg\Commands;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class TestCommand extends Command
{
    protected function configure()
    {
        $this->setName('test');

        $this->setDescription('Returns a "Test" string');
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $output->writeln('Test');
    }
}
```

Before running the command, kindly check if its namespace is defined in `Composer`:

```
// composer.json

// ...

"autoload":
{
  "psr-4":
  {
    "Rrsg\\": "src"
  }
}

// ...
```

```
$ composer dump-autoload
```

```
$ vendor/bin/blueprint test

Test
```

Extending Blueprint
-------------------

[](#extending-blueprint)

To use `Blueprint` as a console application, the `Blueprint` class must be created first:

```
// bin/app.php

use Rougin\Blueprint\Blueprint;

// Return the root from "vendor" --------
$vendor = __DIR__ . '/../../../../';

$default = __DIR__ . '/../';

$loader = '/vendor/autoload.php';

$exists = file_exists($vendor . $loader);

$root = $exists ? $vendor : $default;
// --------------------------------------

// Load the Composer autoloader -------
require $root . '/vendor/autoload.php';
// ------------------------------------

$app = new Blueprint;
```

The following details can now be updated after creating the class:

```
// bin/app.php

// ...

// Sets the directory for the defined commands ----
$app->setCommandPath(__DIR__ . '/../src/Commands');
// ------------------------------------------------

// Sets the directory for the templates. Useful -----
// for creating commands with template engines ------
$app->setTemplatePath(__DIR__ . '/../src/Templates');
// --------------------------------------------------

// Sets the name of the console application ---
$app->setName('Rrsg');
// --------------------------------------------

// Sets the version of the console application ---
$app->setVersion('0.1.0');
// -----------------------------------------------

// Sets the namespace for the "commands" path ---
$namespace = 'Rrsg\Simplest\Commands';

$app->setCommandNamespace($namespace);
// ----------------------------------------------

// Runs the console application ---
$app->run();
// --------------------------------
```

Note

Using this approach means the `blueprint.php` can now be omitted. This approach is also applicable to create customized console applications without the `Blueprint` branding.

Once configured, the console application can now be run in the terminal:

```
$ php bin\app.php

Rrsg 0.1.0

Usage:
  command [options] [arguments]

Options:
  -h, --help            Display help for the given command. When no command is given display help for the list command
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi|--no-ansi  Force (or disable --no-ansi) ANSI output
  -n, --no-interaction  Do not ask any interactive question
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:
  completion  Dump the shell completion script
  help        Display help for a command
  list        List commands
```

Customized `Command`
--------------------

[](#customized-command)

`Blueprint` also provides an alternative `Command` class for creating commands with descriptive methods and less code:

```
// src/Commands/TestCommand.php

namespace Rrsg\Commands;

use Rougin\Blueprint\Command;

class TestCommand extends Command
{
    protected $name = 'test';

    protected $description = 'Returns a "Test" string';

    public function execute()
    {
        $this->showPass('Test');
    }
}
```

Kindly see [COMMAND](https://github.com/rougin/blueprint/blob/master/COMMAND.md) for its available properties and methods.

Note

All of the functionalities for the `Command` class is derived from the [`Symfony's Console` component](https://symfony.com/doc/current/console.html#creating-a-command).

Injecting dependencies
----------------------

[](#injecting-dependencies)

To perform [automagic resolutions](https://github.com/rougin/slytherin/wiki/Container) in each defined commands, the `addPackage` can be used with the additional functionality from the `Container` class from [`Slytherin`](https://roug.in/slytherin/):

```
// src/Sample.php

namespace Rrsg;

class Sample
{
    protected $name;

    public function __construct($name)
    {
        $this->name = $name;
    }

    public function getName()
    {
        return $this->name;
    }
}
```

```
// src/Packages/SamplePackage.php

namespace Rrsg\Packages;

use Rrsg\Sample;
use Rougin\Slytherin\Container\ContainerInterface;
use Rougin\Slytherin\Integration\Configuration;
use Rougin\Slytherin\Integration\IntegrationInterface;

class SamplePackage implements IntegrationInterface
{
    public function define(ContainerInterface $container, Configuration $config)
    {
        return $container->set(Sample::class, new Sample('Blueprint'));
    }
}
```

```
// bin/app.php

use Rrsg\Packages\SamplePackage;
use Rougin\Slytherin\Container\Container;

// ...

// Add the specified package to the container ---
$container = new Container;

$container->addPackage(new SamplePackage);
// ----------------------------------------------

// Then pass it to the console application ---
$app->setContainer($container);
// -------------------------------------------
```

With the above-mentioned integration, for any command that uses the `Sample` class will get the `text` value as the `$name` property:

```
namespace Rrsg\Commands;

use Rrsg\Sample;
use Rougin\Blueprint\Command;

class TextCommand extends Command
{
    protected $name = 'text';

    protected $description = 'Shows a sample text';

    protected $sample;

    public function __construct(Sample $sample)
    {
        $this->sample = $sample;
    }

    public function run()
    {
        $this->showText('Hello, ' . $this->sample->getName() . '!');

        return self::RETURN_SUCCESS;
    }
}
```

```
$ php bin/app.php text

Hello, Blueprint!
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](https://github.com/rougin/blueprint/blob/master/CHANGELOG.md) for more recent changes.

Contributing
------------

[](#contributing)

See [CONTRIBUTING](https://github.com/rougin/blueprint/blob/master/CONTRIBUTING.md) on how to contribute.

License
-------

[](#license)

The MIT License (MIT). Please see [LICENSE](https://github.com/rougin/blueprint/blob/master/LICENSE.md) for more information.

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance90

Actively maintained with recent releases

Popularity26

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~302 days

Recently: every ~876 days

Total

14

Last Release

48d ago

PHP version history (2 changes)v0.1.0PHP &gt;=5.3.0

v0.4.0PHP &gt;=5.4.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/c7721589a958a1fbcef1b527c794d820d75b82988f14b2ed86a1c6904d76a59e?d=identicon)[rougin](/maintainers/rougin)

---

Top Contributors

[![rougin](https://avatars.githubusercontent.com/u/6078637?v=4)](https://github.com/rougin "rougin (110 commits)")

---

Tags

blueprintfile-generatorgeneratorphp-librarygeneratorblueprintphp-console

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rougin-blueprint/health.svg)

```
[![Health](https://phpackages.com/badges/rougin-blueprint/health.svg)](https://phpackages.com/packages/rougin-blueprint)
```

###  Alternatives

[friendsoftypo3/content-blocks

TYPO3 CMS Content Blocks - Content Types API | Define reusable components via YAML

103519.9k53](/packages/friendsoftypo3-content-blocks)[jolicode/castor

A lightweight and modern task runner. Automate everything. In PHP.

54743.1k4](/packages/jolicode-castor)[whatsdiff/whatsdiff

See what's changed in your project's dependencies

771.2k](/packages/whatsdiff-whatsdiff)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

9421.6k61](/packages/open-dxp-opendxp)[aeliot/todo-registrar

Register TODOs from source code in issue tracker

153.0k](/packages/aeliot-todo-registrar)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
