Search code examples
phalcon

Unable to change the echo output


I have used PhalconPHP devtools to create a project skeleton and did some testing in the indexAction(){} from the indexController.

My index controller:

 class IndexController extends ControllerBase

{

    public function indexAction()

    {

        echo "OUUUUUTPUUUUUUUUUUUUUUUT";

    }

}

and index.volt looks like:

 <!DOCTYPE html>

<html>

    <head>

        <title>Phalcon PHP Framework</title>

    </head>

    <body>

    <?php echo $this->view->getContent(); ?>

        {{ content() }}

    </body>

</html>

I know this way I am getting double the content. But this is for debugging. The output I get is:

<h1>Congratulations!</h1>

<p>You are now flying with Phalcon. Great things are about to happen!</p>

<h1>Congratulations!</h1>

<p>You are now flying with Phalcon. Great things are about to happen!</p>

I am using Chrome browser for testing, and Ubuntu server 12.04 for PhalconPHP 1.3.0.


Solution

  • Phalcon view uses output buffering, I'm sure that's the reason why you're not seeing the echo output, since the view has control over that. You can disable the view to print stuff directly from the controller:

    public function indexAction()
    {
        $this->view->disable();
        echo "HELLO";
    }
    

    To address the actual debugging question, I suggest to stick with Xdebug – it works perfectly fine with Phalcon and supported by most IDEs, like PhpStorm or NetBeans, and has browser extensions (Chrome, Safari, etc.) It takes awhile to get the head around the first time, but the time invested is totally worth it. Highly recommend.