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

how to use events in cli?

hi. Can somebody help to understand how use events in cli? for both console:beforeHandleTask and console:afterHandleTask. I write so

$app = new Console();

$eventsManager = $di->getShared('eventsManager');
$eventsManager->attach('console:beforeHandleTask', new CliPlugin());
$eventsManager->attach('console:afterHandleTask', new CliPlugin());


beforeHandleTask fires, but afterHandleTask no. Where is my error?

Does your CLI task exit/die/terminate in any way that wouldn't allow the bootstrapping to complete gracefully? You can see in the Zephir code that the event is definitely there to be fired: https://github.com/phalcon/cphalcon/blob/master/phalcon/cli/console.zep#L234

Which version of Phalcon are you running, and on what architecture?