# Laminas-cli: There are no commands defined in the "order" namespace

**URL:** https://discourse.laminas.dev/t/laminas-cli-there-are-no-commands-defined-in-the-order-namespace/3707
**Category:** Components & MVC
**Tags:** laminas-cli
**Created:** [June 3, 2024, 8:19pm UTC](https://discourse.laminas.dev/t/laminas-cli-there-are-no-commands-defined-in-the-order-namespace/3707 "2024-06-03T20:19:43Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![modir](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/modir/32/930_2.png) [@modir](https://discourse.laminas.dev/u/modir)
#### Post date: [June 3, 2024, 8:19pm UTC](https://discourse.laminas.dev/t/laminas-cli-there-are-no-commands-defined-in-the-order-namespace/3707/1 "2024-06-03T20:19:43Z")

</div>

I somehow don’t understand the intro fully. I added the configurations either directly as described in the first four steps at [Introduction - laminas-cli - Laminas Docs](https://docs.laminas.dev/laminas-cli/intro/) or I added in the module configuration. I always get the error message `There are no commands defined in the "order" namespace.` The command I want to implement is `order:import-orders`. Is the namespace written here about the PHP namespace? Because in the linked documentation it is written as “package”. So somehow I assume it is something totally different.

Can someone enlighten me?

---

<div class="post-metadata">

### Author: ![Tyrsson](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/tyrsson/32/1664_2.png) [@Tyrsson](https://discourse.laminas.dev/u/Tyrsson)
#### Post date: [June 3, 2024, 11:04pm UTC](https://discourse.laminas.dev/t/laminas-cli-there-are-no-commands-defined-in-the-order-namespace/3707/2 "2024-06-03T23:04:40Z")

</div>

Can you show us your config?

---

<div class="post-metadata">

### Author: ![modir](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/modir/32/930_2.png) [@modir](https://discourse.laminas.dev/u/modir)
#### Post date: [June 4, 2024, 9:28pm UTC](https://discourse.laminas.dev/t/laminas-cli-there-are-no-commands-defined-in-the-order-namespace/3707/3 "2024-06-04T21:28:44Z")

</div>

Sure. The module.config.php has the following entries:

```auto
    'dependencies' => [
        'factories' => [
            \Order\Console\OrderImport::class => \Order\Console\Factory\OrderImportFactory::class,
        ],
    ],
    'laminas-cli' => [
        'commands' => [
            'order:import-orders' => Console\OrderImport::class,
             ],
    ]

```

I already tried to move the dependencies to the file `config/autoload/dependencies.global.php` but this didn’t help much either. Then I tried to move the "laminas-cli array to the global.php config but this didn’t help either.

---

<div class="post-metadata">

### Author: ![ALTAMASH80](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/altamash80/32/895_2.png) [@ALTAMASH80](https://discourse.laminas.dev/u/ALTAMASH80)
#### Post date: [June 5, 2024, 5:34am UTC](https://discourse.laminas.dev/t/laminas-cli-there-are-no-commands-defined-in-the-order-namespace/3707/4 "2024-06-05T05:34:51Z")

</div>

Shouldn’t one be using FCQN everywhere rather than in some cases? In your opinion both below FCQN are the same?

```auto
'some-factory' => \Order\Console\OrderImport:class,
'I-call-it-like' => Console\OrderImport::class 

```

Thanks!

---

<div class="post-metadata">

### Author: ![modir](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/modir/32/930_2.png) [@modir](https://discourse.laminas.dev/u/modir)
#### Post date: [June 5, 2024, 9:54am UTC](https://discourse.laminas.dev/t/laminas-cli-there-are-no-commands-defined-in-the-order-namespace/3707/5 "2024-06-05T09:54:38Z")

</div>

I already tried both versions. I tried the FCQN because i moved this part of the code once to the dependencies.global.php as written above. So this is not the solution. But thanks anyway.

---

<div class="post-metadata">

### Author: ![ezkimo](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/ezkimo/32/781_2.png) [@ezkimo](https://discourse.laminas.dev/u/ezkimo)
#### Post date: [June 5, 2024, 12:20pm UTC](https://discourse.laminas.dev/t/laminas-cli-there-are-no-commands-defined-in-the-order-namespace/3707/6 "2024-06-05T12:20:59Z")

</div>

Hey …

The exception was thrown directly from the symfony console component, from which laminas-cli inherits. Symfony console tries to fiend a namespace, which is obviously not defined.

First of all … you are using Laminas MVC and not the middleware components of Mezzio, right? The service manager used with Laminas MVC does not use a `dependency` config entry. Have you tried a `service_manager` config entry instead?

```auto
// config/module.config.php
namespace Order;
return [
    'service_manager' => [
        'factories' => [
            Console\OrderImport::class => Console\Factory\OrderImportFactory::class,
        ],
    ],
    'laminas_cli' => [
        'commands' => [
            'order:import-orders' => Console\OrderImport::class,
         ],
    ]
];

```

The given example from [Introduction - laminas-cli - Laminas Docs](https://docs.laminas.dev/laminas-cli/intro/) works with a global `config/autoload/dependencies.global.php` file, which is stated out in the given components example.

---

<div class="post-metadata">

### Author: ![modir](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/modir/32/930_2.png) [@modir](https://discourse.laminas.dev/u/modir)
#### Post date: [June 5, 2024, 10:01pm UTC](https://discourse.laminas.dev/t/laminas-cli-there-are-no-commands-defined-in-the-order-namespace/3707/7 "2024-06-05T22:01:20Z")

</div>

Thanks @ezkimo. Yes, I do use Laminas MVC. I tried it now with the `service_manager` but no luck either. Do I have to write now a ConfigProvider or is this only needed for Mezzio? It looks to me like a lot in there is configured like what I already have in the module.config.php

---

<div class="post-metadata">

### Author: ![ALTAMASH80](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/altamash80/32/895_2.png) [@ALTAMASH80](https://discourse.laminas.dev/u/ALTAMASH80)
#### Post date: [June 6, 2024, 5:13am UTC](https://discourse.laminas.dev/t/laminas-cli-there-are-no-commands-defined-in-the-order-namespace/3707/8 "2024-06-06T05:13:35Z")

</div>

@modir,  
One of the differences between Mezzio and Laminas MVC is that Laminas MVC reads/registers a module via Module.php file and Mezzio with ModuleName:space::ConfigProvider::class. If you want your module to be used in Mezzio then and only then use the ConfigProvider::class otherwise everything is fine.

> [@modir](#):
>
> Do I have to write now a ConfigProvider or is this only needed for Mezzio? It looks to me like a lot in there is configured like what I already have in the module.config.php

If you analyze the code it is doing exactly the something when you configure a module via a module.config.php file. As I’ve said above the usage of ConfigProvider class is there if you want to use/reuse your module in Mezzio. Even then it will not be a walk in the park.

From what I’ve understood from your conversation is that you’ve only followed the what is written in the tutorial and that is the code itself. It might be the case that you’ve not registered your Module in composer.json file. Have you add this line in your composer.json file?

```auto
//composer.json file
{
     ...
    "autoload": {
        "psr-4": {
            //Do you've got this line in your composer.json file?
            "Order\\": "module/Order/src/"
        },
    }
}

```

If not, then after adding the above line do the following.

```auto
composer autoload-dump
composer clear-config-cache

```

I hope I’ve answered your question.

---

<div class="post-metadata">

### Author: ![modir](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/modir/32/930_2.png) [@modir](https://discourse.laminas.dev/u/modir)
#### Post date: [June 6, 2024, 7:24am UTC](https://discourse.laminas.dev/t/laminas-cli-there-are-no-commands-defined-in-the-order-namespace/3707/9 "2024-06-06T07:24:30Z")

</div>

Yes, I have this code in my composer.json file. My module is working for already 5 years. I am in the process of moving from laminas-console to laminas-cli. And I just can’t get laminas-cli to work.

---

<div class="post-metadata">

### Author: ![modir](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/modir/32/930_2.png) [@modir](https://discourse.laminas.dev/u/modir)
#### Post date: [June 6, 2024, 8:04am UTC](https://discourse.laminas.dev/t/laminas-cli-there-are-no-commands-defined-in-the-order-namespace/3707/10 "2024-06-06T08:04:53Z")

</div>

I got it working now. The problem was a mix of not having the service\_manager config plus then forgetting to clear the config cache at the end. Stupid me. Thanks everyone.

---

<div class="post-metadata">

### Author: ![ALTAMASH80](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/altamash80/32/895_2.png) [@ALTAMASH80](https://discourse.laminas.dev/u/ALTAMASH80)
#### Post date: [June 6, 2024, 8:23am UTC](https://discourse.laminas.dev/t/laminas-cli-there-are-no-commands-defined-in-the-order-namespace/3707/11 "2024-06-06T08:23:52Z")

</div>

Thanks for letting me know I was speaking an alien language.

---

<div class="post-metadata">

### Author: ![froschdesign](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/froschdesign/32/38_2.png) [@froschdesign](https://discourse.laminas.dev/u/froschdesign)
#### Post date: [June 6, 2024, 8:38am UTC](https://discourse.laminas.dev/t/laminas-cli-there-are-no-commands-defined-in-the-order-namespace/3707/12 "2024-06-06T08:38:39Z")

</div>

> [@modir](#):
>
> …then forgetting to clear the config cache at the end.

Typical problem. The development mode helps:

> **[The Skeleton Application - tutorials - Laminas Docs](https://docs.laminas.dev/tutorials/getting-started/skeleton-application/#development-mode)**
>
> Learn how to create laminas-mvc applications, get in-depth guides into components, and discover how to migrate your applications to version 3!

---

<div class="post-metadata">

### Author: ![modir](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/modir/32/930_2.png) [@modir](https://discourse.laminas.dev/u/modir)
#### Post date: [June 6, 2024, 9:05am UTC](https://discourse.laminas.dev/t/laminas-cli-there-are-no-commands-defined-in-the-order-namespace/3707/13 "2024-06-06T09:05:56Z")

</div>

@ALTAMASH80 When two developers are not on the same level then it can indeed happen that some text from one person is to the other like alien language. Now in retrospective it makes sense what you wrote. I just couldn’t connect it with my problem.

---

<div class="post-metadata">

### Author: ![modir](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/modir/32/930_2.png) [@modir](https://discourse.laminas.dev/u/modir)
#### Post date: [June 6, 2024, 9:08am UTC](https://discourse.laminas.dev/t/laminas-cli-there-are-no-commands-defined-in-the-order-namespace/3707/14 "2024-06-06T09:08:12Z")

</div>

Very good point from you @froschdesign At the moment we are slowly getting more modern with the code. At one time I will clean this up as well.

---

<div class="post-metadata">

### Author: ![Tyrsson](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/tyrsson/32/1664_2.png) [@Tyrsson](https://discourse.laminas.dev/u/Tyrsson)
#### Post date: [June 6, 2024, 11:00pm UTC](https://discourse.laminas.dev/t/laminas-cli-there-are-no-commands-defined-in-the-order-namespace/3707/15 "2024-06-06T23:00:18Z")

</div>

> [@modir](#):
>
> Is the namespace written here about the PHP namespace?

> [@modir](#):
>
> ```auto
> 'laminas-cli' => [
> 'commands' => [
> 'order:import-orders' => Console\OrderImport::class,
> ],
> ]
> 
> ```

@modir  
The

“order:”

portion here is the namespace.

Take the following example

```auto
    public function getConsoleConfig(): array
    {
        return [
            'commands' => [
                'axleus:db:write-config' => Console\Command\DbConfigCommand::class,
                'axleus:db:create' => Console\Command\BuildDbCommand::class,
            ],
        ];
    }

```

Those commands live in the Php namespace:  
namespace Axleus\DevTools\Console\Command;

The command namespace is axleus:db: which is independent of the Php namespace.

This allows you to aggregate commands from many different “modules/components” into a single “suite” of commands exposed by the application.

In this example they are all for the axleus application, the example targets the db component.

---

<div class="post-metadata">

### Author: ![modir](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/modir/32/930_2.png) [@modir](https://discourse.laminas.dev/u/modir)
#### Post date: [June 7, 2024, 9:54am UTC](https://discourse.laminas.dev/t/laminas-cli-there-are-no-commands-defined-in-the-order-namespace/3707/16 "2024-06-07T09:54:15Z")

</div>

> [@Tyrsson](#):
>
> @modir  
> The command namespace is axleus:db: which is independent of the Php namespace.
> 
> This allows you to aggregate commands from many different “modules/components” into a single “suite” of commands exposed by the application.

Thanks. This was an important part of the information I was missing. The documentation was just not very clear on this.
