snowair / phalcon-debugbar

A powerful debug and profilers tool for the Phalcon Framework
MIT License
162 stars 49 forks source link

Debugbar messages not working #40

Closed cosmy81 closed 7 years ago

cosmy81 commented 7 years ago

HI, I have the debugbar working on my site, but the messages are not working. The debugbar inizialization is: (new Snowair\Debugbar\ServiceProvider(BASE_PATH . '/config/debugbar.php'))->start(); Then if I try to use it, nothing happens:

<?php
          $debugbar=$di->get('debugbar');
          $debugbar->startMeasure('start-1','how long');        // startMeasure($internal_sign_use_to_stop_measure, $label)
          $debugbar->addMeasurePoint('start');                  // measure the spent time from latest measurepoint to now.
          $debugbar->addMessage('this is a message', 'label');  // add a message using a custom label.
          $debugbar->info(ENVIRONMENT,SITENAME);  // add many messages once a time. See PSR-3 for other methods name.(debug,notice,warning,error,...)
          $debugbar->addMessageIfTrue('1 == "1"', 1=='1','custom_label'); // add message only when the second parameter is true
          $debugbar->addMessageIfTrue('will not show', 1=='0');
          $debugbar->addMessageIfFalse('1 != "0" ', 1=='0');       // add message only when the second parameter is false
          $debugbar->addMessageIfNull('condition is null', Null ); // add message only when the second parameter is NULL
          $condition='';
          $debugbar->addMessageIfEmpty('condition is emtpy', $condition ); // add message only when the second parameter is empty
          $debugbar->addMessageIfNotEmpty('condition is not emtpy', $condition=[1] ); // add message only when the second parameter is not empty
          $debugbar->addException(new \Exception('oh , error'));
          $debugbar->addMeasurePoint('stop');
          $debugbar->stopMeasure('start-1');                    // stopMeasure($internal_sign_use_to_stop_measure)

If I try inside volt template I receive an error: {{ addMessage('test message','label') }}

Macro 'addMessage' does not exist

0 /Users/cosmy/git/BraveNewSystem/cache/volt/weekendinitaly/%%users%%cosmy%%git%%bravenewsystem%%app%%frontend%%weekendinitaly%%views%%index%%index.volt.compiled(4): Phalcon\Mvc\View\Engine\Volt->callMacro('addMessage', Array)

1 [internal function]: unknown()

2 /Users/cosmy/git/BraveNewSystem/lib/extended/ExtendedView.php(63): Phalcon\Mvc\View\Engine\Volt->render('/Users/cosmy/gi...', Array, true)

3 [internal function]: Extended\ExtendedView->_engineRender(Array, 'index/index', true, true, NULL)

4 [internal function]: Phalcon\Mvc\View->render('index', 'index', Array)

5 /Users/cosmy/git/BraveNewSystem/app/Bootstrap.php(155): Phalcon\Mvc\Application->handle()

6 /Users/cosmy/git/BraveNewSystem/public/index.php(23): Bootstrap->run()

7 {main}

snowair commented 7 years ago
  1. enable the "view" collector
  2. delete all files in the "cache/volt" directory

then retry.