We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Register Services in CLI Modules

Hello, I have a Project which is divided in Modules. The Project can be run over web and additionaly over cli. My problem is, that the cli-verison doesnt set shared dependencies which are defined in my Module.php

Entry:

...
$di = new CliDI();
$console = new ConsoleApp($di);

require __DIR__ . '/../app/config/services.php';
require __DIR__ . '/../app/config/servicesCli.php';

$namespace = "Xxx\\Tasks\\Tasks\\";
.....

servicesCli.php

...
$console->registerModules(
    [
        'xxxTasks' => [
            'className' => 'Xxx\XxxTasks\Module',
            'path' => '../app/modules/xxx_tasks/Module.php'
        ],
    ]
);
...

Module.php

/**
     * @param DiInterface $di
     */
    public function registerServices(DiInterface $di)
    {
        parent::registerServices($di);

        $di->get('dispatcher')->setDefaultNamespace('Xxxx\User\Controllers');
        $di->get('view')->setViewsDir(__DIR__ . '/views/');

        $di->setShared('proxyServerConfig', function() {
            return require APP_PATH . '/app/config/proxy_server_config.php';
        });
    }

So proxyServerConfig isn't set as dependency. If I add setShared("proxyServerConfig"... into servicesCli.php everything works.

Most likely CLI application just doesn't call those methods...