Enabling production mode removes cli commands from the list

Enabling production mode removes cli commands from the list. By enabling development mode it appears. Thanks!

Are your commands defined in the development.config.php file?

No, they’re in the Application module getConfig method like below.

public function getConfig(){
  $cliConfigArray = [
            'laminas-cli' => $configProvider->getCliConfig(),
            'service_manager' => $configProvider->getDependencyConfig(),
        ];

        return array_merge( include __DIR__ . '/../config/module.config.php',  $cliConfigArray );
} 

Thanks!

I’m trying to understand what the purpose of the “extra” work is here? It’s clear that you have introduced a config provider in the Application module, which I have never seen one setup that way but… Since, you have… Why not just return the array as usual and each key have the method return as the value instead of merging the config file? I’m sure there must be a reason, I am just not seeing it (It has been a VERY long day at the day job lol).

Quick question. What does the getCliConfig method look like? and what does the module.config.php file look like? Only the relevant part of the config file of course.

Hi @Tyrsson,

This configuration method is introduced in Mezzio the child of Laminas MVC. You can look at it here. Thanks!

I’m aware of it, and use it, some times (both the cli and the ConfigProdiver approach to application configuration). Which is what had me thrown for a loop cause “usually” there is only a Module.php and the ConfigProvider class.

Is this in MVC or Mezzio? Just to be clear…

Is any part of that file being cached when you move to production mode? Or is it just the command config that you are losing?

Hi @Tyrsson,

Thanks for the wake-up call. Yes, the production uses a cache all the time. What a beginner’s mistake from my side. I’ve to remember that on production I’ve to keep re-cache after a deployment. This config is in Laminas MVC. I’ve not understood Mezzio as it is a copy of Laminas MVC with the difference of Middleware. I’ve not found anything special about Mezzio yet.

It is definitely not a copy, because it follows a fundamentally different approach. The whole structure is much simpler and therefore easier for the user to use. This starts with the creation, continues with the understanding and ends with the testing of the application. You don’t need to know anything about the event manager and all the MVC events, the module manager or different types of controllers.

The learning curve, from getting started to building the first application, is significantly lower with Mezzio

2 Likes