We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Event after Task in Console Application

How do add an event to run after running a console task? I'm basically trying to add a debug event after running the console task to print out queries, time taken, etc.


You can attach an events manager to cli/console:


$em = new Phalcon\Events\Manager();

$em->attach("console:afterHandleTask", function($event, $console) {
    //Executed after handle the task

$console = new Phalcon\CLI\Console();



thanks, worked perfectly!