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.



81.8k

You can attach an events manager to cli/console:

<?php

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

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

$console = new Phalcon\CLI\Console();
$console->setEventsManager($em);

$console->handle(...);


3.8k

thanks, worked perfectly!