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 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.
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.
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.
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?
The given example from Introduction - laminas-cli - Laminas Docs works with a global config/autoload/dependencies.global.php file, which is stated out in the given components example.
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
@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.
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?
//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.
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.
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.
@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.