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

Response can't send() automic where setJsonContent() method is called

in my Micro App,

use middleware “after”,like below:

<?php
......
$app->after(function () use ($app) {
    $result = $app->getReturnedValue();

    if(is_array($result) || is_object($result)){
        $app->response->setJsonContent($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
        // must add this line
        $app->response->send();
    } else {
        $app->response->setContent($result);    
    }
});
...

....
$app->handle();
?>

when my response setJsonContent(),the response must be "$app->response->send()" manual。 but when response setContent() ,it does not need use "$response->send()" method.

is it a bug?

edited Mar '17

Yes this is correct, send is only done if returned value is string or response object. This could be changed though imho to change value of returned value in micro because it's possible in mvc, create issue on github maybe.