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.0(1y ago)37.6k3MITPHPPHP &gt;=5.3.0CI passing

Since Aug 9Pushed 6mo 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 1mo ago

READMEChangelog (10)Dependencies (5)Versions (14)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.yml` file using the `initialize` command:

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

```
# blueprint.yml

name: Blueprint
version: 0.7.0

paths:
  templates: %%CURRENT_DIRECTORY%%/src/Templates
  commands: %%CURRENT_DIRECTORY%%/src/Commands

namespaces:
  commands: Rougin\Blueprint\Commands
```

Note

- Replace the values specified in the `blueprint.yml` file.
- Add commands and templates (if applicable) to their respective directories.

To write a command, the `commands` property in `blueprint.yml` must be updated first:

```
# blueprint.yml

# ...

namespaces:
  commands: Acme\Commands
```

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

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

namespace Acme\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":
  {
    "Acme\\": "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('Acme');
// ---------------------------------------------

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

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

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

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

Note

Using this approach means the `blueprint.yml` 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

Acme 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 Acme\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 Acme;

class Sample
{
    protected $name;

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

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

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

namespace Acme\Packages;

use Acme\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 Acme\Packages\SamplePackage;
use Rougin\Slytherin\Container\Container;

// ...

// Add the specified integration (or package) to the container ---
$container = new Container;

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

// Set the container 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 Acme\Commands;

use Acme\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

39

—

LowBetter than 86% of packages

Maintenance54

Moderate activity, may be stable

Popularity24

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity55

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 ~279 days

Recently: every ~742 days

Total

13

Last Release

575d 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 (102 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

[tightenco/jigsaw

Simple static sites with Laravel's Blade.

2.2k438.5k29](/packages/tightenco-jigsaw)[crunzphp/crunz

Schedule your tasks right from the code.

2292.0M6](/packages/crunzphp-crunz)[wsdltophp/packagegenerator

Generate hierarchical PHP classes based on a WSDL

4351.9M19](/packages/wsdltophp-packagegenerator)[crazywhalecc/static-php-cli

Build single static PHP binary, with PHP project together, with popular extensions included.

1.8k13.9k](/packages/crazywhalecc-static-php-cli)[phpcr/phpcr-shell

Shell for PHPCR

721.3M8](/packages/phpcr-phpcr-shell)[madewithlove/license-checker

CLI tool to verify allowed licenses for composer dependencies

54449.8k21](/packages/madewithlove-license-checker)

PHPackages © 2026

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