PHPackages                             visto9259/laminas-console-symfony - 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. visto9259/laminas-console-symfony

ActiveLibrary

visto9259/laminas-console-symfony
=================================

A Laminas Framework Console application based on Symfony Console

1.0.0(6y ago)0218[2 issues](https://github.com/visto9259/laminas-console-symfony/issues)[2 PRs](https://github.com/visto9259/laminas-console-symfony/pulls)MITPHP

Since Feb 17Pushed 2y ago2 watchersCompare

[ Source](https://github.com/visto9259/laminas-console-symfony)[ Packagist](https://packagist.org/packages/visto9259/laminas-console-symfony)[ RSS](/packages/visto9259-laminas-console-symfony/feed)WikiDiscussions master Synced 2d ago

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

Laminas-Console-Symfony: A Laminas MVC console app using Symfony Console
========================================================================

[](#laminas-console-symfony-a-laminas-mvc-console-app-using-symfony-console)

Introduction
------------

[](#introduction)

`laminas-console-symfony` provides a replacement for `zf-console` with a wrapper for the `symfony/console` component.

For developers familiar with Laminas MVC application, this package is inspired by `laminas-mvc` in its usage of modules and dependency injection using the Service Manager.

Requirements
------------

[](#requirements)

Please see the [composer.json](composer.json) file.

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

[](#installation)

Run the following `composer` command:

```
$ composer require visto9259/laminas-console-symfony

```

Or, alternatively, manually add the following to your `composer.json`, in the `require` section:

```
"require" : {
    "visto9259/laminas-console-symfony" : "^1.0.0"
}

```

And then run `composer update` to ensure the module is installed.

Creating a console application
------------------------------

[](#creating-a-console-application)

The console application skeleton is based on the Laminas Framework MVC Application skeleton. It follows a similar directory structure:

```
MyApp/
   config/
      autoload/
         global.php
         local.php
         ... other config files
      application.config.php
      modules.config.php
      commands.config.php
      development.config.php (optional)
   module/
      myModule/
        config/
           module.config.php (optional)
        src/
           Module.php
   vendor/
      composer/
      ...
      autoload.php (created by Composer)
   myapp.php (entry point of the application)

```

The `myapp.php` file contains the console application code and can be as simple as:

```
require __DIR__.'/vendor/autoload.php';

use Laminas\Stdlib\ArrayUtils;
use LaminasSymfonyConsole\Application;

// Setup the application
$appConfig = require __DIR__ . '/config/application.config.php_dist';
if (file_exists(__DIR__ . '/config/development.config.php')) {
   $appConfig = ArrayUtils::merge($appConfig, require __DIR__ . '/config/development.config.php');
}
$application = new Application($appConfig);

$exit = $application->run();
```

### Configuring the application

[](#configuring-the-application)

The file `application_config.php` provides the configuration for the console application and for the loading of the modules using the Laminas Framework Module Manager. It contains the following:

```
return [
    'console_application_options' => [
        'name' => 'Test',
        'version' => '0.1',
    ],
    'commands' => require __DIR__ . '/commands.config.php_dist',
    'modules' => require __DIR__ . '/modules.config.php',
    'module_listener_options' => [
        'module_paths' => [
            './module',
            './vendor',
        ],
        'config_glob_paths' => [
            realpath(__DIR__) . '/autoload/{{,*.}global,{,*.}local}.php',
        ],
    ],
    'service_manager' => [
        // typical Service Manager configation
    ],
];
```

`console_application_options` contains the `$name` and `$version` arguments passed to `Symfony\Component\Console\Application` constructor.

`commands` is an array of command configurations. See [Defining Commands](#DefiningCommands) for details.

`modules` and `module_listener_options` are the Module Manager configuration parameters.

`service_manager` contains the typical Laminas Framework Service Manager configuration which allows for services, factories and so on to be defined.

#### Differences with `laminas-mvc` applications

[](#differences-with-laminas-mvc-applications)

This application is inspired by the `laminas-mvc` application but it is not intended to implement a full-fledge MVC application. It is a wrapper around the Symfony Console Application that provides a Service Manager for dependency injection and uses the Module Manager to load modules.

The intent is that if one wants to use an existing or a custom Laminas module, it can be added to the list of modules to be loaded. For example, if a module defines services to access a database, it will be loaded by the Module Manager and its services added to the Service Manager.

#### Limitations in Module Configuration

[](#limitations-in-module-configuration)

The LaminasConsoleSymfony application uses the Module Manager `loadModules()` method to load modules but will only service modules that implement the `ServiceProviderInterface` and the `ConfigProviderInterface`interfaces. All other provider interfaces are ignored.

**Important:** The Module class **SHOULD NOT** implement the `BootstrapListenerInterface` and `InitProviderInterface` for the time being. These will make the application crash.

### Defining commands

[](#defining-commands)

Symfony Console commands can be defined in the `config/commands.config.php`. They will be instantiated and added to Console application when it is created.

A typical `commands.config.php` would contain the following:

```
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use LaminasSymfonyConsole\Factory\AbstractCommandFactory;

return [
    'commands' => [
        [
            'name' => 'test',
            'description' => 'Test command',
            'help' => 'Test help message',
            'class' => Test::class,
            'arguments' => [
                [
                    'name' => 'arg1',
                    'mode' => InputArgument::OPTIONAL,
                    'description' => 'Argument 1',
                ],
                [
                    'name' => 'arg2',
                    'mode' => InputArgument::OPTIONAL,
                    'description' => 'Argument 2',
                    'default' => 'some default',
                ],
            ],
            'options' => [
                [
                    'name' => 'yell',
                    'shortcut' => 'y',
                    'mode' => InputOption::VALUE_REQUIRED,
                    'description' => 'yell option',
                ],
            ],
        ],
    ],
    'service_manager' => [
        'factories' => [
            Test::class => AbstractCommandFactory::class,
        ]
    ]
];
```

`commands` is an array of Symfony Command definitions. The `name`, `description` and `help` usage is defined in the Symfony Command documentation. The`arguments` and `options` arrays contains lists of Symfony `InputArgument`and `InputOptions` definitions.

The `class` element of a command definition refers to the name of the class that implements the Symfony Command. It is mandatory that the class extends the `Symfony\Component\Console\Command\Command` class. `class`can either by a class name or a string. The application will use the Laminas Framework Service Manager to instantiate the class which allows for the use of factories to create the command and inject dependencies. `class` can also be an instance of a `Symfony\Component\Console\Command\Command` class.

`service_manager` contains the typical Service Manager configuration that will be added to the application Service Manager.
If a Command does not need a specific factory to create it, the `class` element of the Command definition can simply provide the class name of the Command and the Service Manager will use `AbstractCommandFactory` to create the command.

Feedback
--------

[](#feedback)

This package is work-in-progress. It has not been thoroughly tested for all thinkable cases. If you find a problem, please log an issue.

I am also very opened to feedback and suggestions for improvements.

###### © 2019 Eric Richer ()

[](#-2019-eric-richer-ericrichervistoconsultingcom)

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 94.4% 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

Unknown

Total

1

Last Release

2276d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/39ff13f678d45f5296af1e1a2a5807db794bfd9835b64302c9bcc43156854a03?d=identicon)[visto9259](/maintainers/visto9259)

---

Top Contributors

[![visto9259](https://avatars.githubusercontent.com/u/7890483?v=4)](https://github.com/visto9259 "visto9259 (17 commits)")[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (1 commits)")

---

Tags

laminas-mvcsymfony-consolezf-console

### Embed Badge

![Health badge](/badges/visto9259-laminas-console-symfony/health.svg)

```
[![Health](https://phpackages.com/badges/visto9259-laminas-console-symfony/health.svg)](https://phpackages.com/packages/visto9259-laminas-console-symfony)
```

###  Alternatives

[magento/community-edition

Magento 2 (Open Source)

12.1k52.1k10](/packages/magento-community-edition)[wheelpros/fitment-platform-api

Magento 2 (Open Source)

12.1k1.2k](/packages/wheelpros-fitment-platform-api)[shlinkio/shlink

A self-hosted and PHP-based URL shortener application with CLI and REST interfaces

4.8k4.3k](/packages/shlinkio-shlink)[doctrine/doctrine-orm-module

Laminas Module that provides Doctrine ORM functionality

4407.3M293](/packages/doctrine-doctrine-orm-module)[elgg/elgg

Elgg is an award-winning social networking engine, delivering the building blocks that enable businesses, schools, universities and associations to create their own fully-featured social networks and applications.

1.7k15.7k5](/packages/elgg-elgg)[doctrine/doctrine-mongo-odm-module

Laminas Module which provides Doctrine MongoDB ODM functionality

86676.6k35](/packages/doctrine-doctrine-mongo-odm-module)

PHPackages © 2026

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