2017 © Pedro Peláez
 

library phalcon-debugbar

Integrates PHP Debug Bar with Phalcon.

image

snowair/phalcon-debugbar

Integrates PHP Debug Bar with Phalcon.

  • Sunday, October 15, 2017
  • by snowair
  • Repository
  • 22 Watchers
  • 136 Stars
  • 29,157 Installations
  • PHP
  • 4 Dependents
  • 0 Suggesters
  • 28 Forks
  • 8 Open issues
  • 44 Versions
  • 8 % Grown

The README.md

Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

Phalcon Debugbar

Integrates PHP Debug Bar with Phalcon Framework., (*2)

中文说明, (*3)

Features

  1. Normal request capturing
  2. Ajax request capturing
  3. Redirect request chain capturing
  4. Simple App, Multi module App and Micro App support
  5. Data collected persistent : save to Local File or MongoDB, or ElasticSearch
  6. Data storaged by sessionid, it's more firendly for team development.
  7. You can close inject debugbar, and on a new browser tab, visit /_debugbar/open to see data(and it alse can be disabled).
  8. Whoops Integration, and debugbar works well with it.
  9. Support palcon 1.3.x,2.x,3.x, PHP5.5~7.1

Support Collectors

  • MessagesCollector: Collect custom message, support scalar, array and object
  • TimeDataCollector: Collect custom time measure.
  • ExceptionsCollector: Add a exception object to debugbar.
  • MemoryCollector: Collect memory usage
  • QueryCollector: Capture each SQL statement, measure spent time of each SQL, show EXPLAIN result of each SELECT statement
    • collect information from the db service. Only for Phalcon ORM.
  • DoctrineCollector: Capture each SQL statement in Doctrine, measure spent time of each SQL.
    • collect information from the entityManager service. Only for Doctrine ORM.
  • RouteCollector: Show Route info of current request.
    • collect information from the router service.
  • ViewCollector: Show all the rendered templates, measure spent time of each template, show all the templates variables.
    • collect information from the view service.
  • PhalconRequestCollector: Show request headers, cookies, server variables, response headers, querys, post data,raw body
    • collect information from the request service.
  • ConfigCollector: Show the data in the config service.
    • collect information from the config service.
  • SessionCollectior: Show session data
    • collect information from the session service.
  • SwiftMailCollector: mailer info
    • collect information from the mail service.
  • LogsCollectors: Show logs of current request. Support Phalcon\Logger and Monolog
    • collect information from the log service.
  • CacheCollectors: Show caches summary (saved,gets,incs,decs,failds), and each cache operation detail.
    • collect information from the cache service.

Quick start

composer

  • install, (*4)

    php composer.phar require --dev snowair/phalcon-debugbar
    
  • update, (*5)

    php composer.phar update snowair/phalcon-debugbar
    

Modify index.php

  1. Set your App Instance to DI:, (*6)

    $application = new Phalcon\Mvc\Application( $di ); // Important: mustn't ignore $di param . The Same Micro APP: new Phalcon\Mvc\Micro($di);
    $di['app'] = $application; //  Important
    
  2. Before handle app, register and boot debugbar provider., (*7)

    (new Snowair\Debugbar\ServiceProvider())->start();
    // after start the debugbar, you can do noting but handle your app right now.
    echo $application->handle()->getContent();
    
  3. optional to use Whoops, modify the index.php, add follow codes bellow the debugbar service start() method., (*8)

    (new \Snowair\Debugbar\Whoops\WhoopsServiceProvider($di));
    

Modify The ACL Code

Here is a example for INVO:, (*9)

public function beforeDispatch(Event $event, Dispatcher $dispatcher)
    {
        $auth = $this->session->get('auth');
        if (!$auth){
            $role = 'Guests';
        } else {
            $role = 'Users';
        }

        $controller = $dispatcher->getControllerName();
        $action = $dispatcher->getActionName();

        /* Debugbar start */
        $ns = $dispatcher->getNamespaceName();
        if ($ns=='Snowair\Debugbar\Controllers') {
            return true;
        }
        /* Debugbar end */

        $acl = $this->getAcl();
        $allowed = $acl->isAllowed($role, $controller, $action);
        if ($allowed != Acl::ALLOW) {
            $dispatcher->forward(array(
                'controller' => 'errors',
                'action'     => 'show401'
            ));
                        $this->session->destroy();
            return false;
        }
    }

Data Persistent

For file driver, the default directory for store debugbar data is Runtime/phalcon. If it doesn't exist, it will be created automatically. You can change it by reconfig., (*10)

For mongodb driver, You must install the mongodb extension and install the phplib : composer require mongodb/mongodb, (*11)

For elastic driver, You must install the phplib : composer require elasticsearch/elasticsearch:some-version, (*12)

About baseUri

Be aware of the baseUri configuration of your project, you must set a currect baseUri for your uri service., (*13)

If you are using apache, you should enable the Rewrite mod and have a .htaccess file under the baseUri directory., (*14)

If you are using nginx, you should enable the Rewrite mod and edit the location block of the server configuration like this:, (*15)

    location @rewrite {
        # replace 'baseuri' to your real baseuri
        rewrite ^/baseuri/(.*)$ /baseuri/index.php?_url=/$1;
    }

More

Use your config

Copy config/debugbar.php to your config directory, and change any settings you want. Then use your debugbar config file by:, (*16)

(new Snowair\Debugbar\ServiceProvider('your-debugbar-config-file-path'))->start();

Send custom messages to debugbar

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

Volt Functions:

addMessage
addMessageIfTrue
addMessageIfFalse
addMessageIfNull
addMessageIfEmpty
addMessageIfNotEmpty
addException
addMeasurePoint
startMeasure
stopMeasure
debug/info/notice/warning/error/emergency/critical

Examples

{{ debug( var1, var2 )}}
{{ info( var1, var2 )}}
{{ addMessageIfTrue('$var === true', var ) }}

Multi Modules

Usually, You needn't modify any other files, if you follow rules bellow:, (*17)

  1. All the services for cache has a name contain cache.
  2. All the services for db has a name start with db or end with db.
  3. Visit /_debugbar/open?m={modulename} to open a independent debugbar page.

If your service name is't match these rules, you need attach it to debugbar:, (*18)

// service.php
$di->set('read-db-test',function(...)); // db service
$di->set('redis',function(...)); // cache service
if ( $di->has('debugbar') ) {
    $debugbar = $di['debugbar'];
    $debugbar->attachDb('read-db-test');
    $debugbar->attachCache('redis');
}

Troubleshooting

  • I strongly suggest you to assign a host domain to your project, and set the baseUri of uri service to /., (*19)

  • For ajax/json request, the debug data only stored in the persistent directory as a json file. You can Load it to the debugbar form Openhandler(Open icon on the right)., (*20)

  • If the debugbar does not work, the most likely reason is that one or more collectors triggered a error in the runtime. You can modify the debugbar config file, close collector one by one, retry it until found the collector cause problem., (*21)

  • For any problems, you can open an Issue on Github., (*22)

Snapshots


Screenshot, (*23)


Screenshot, (*24)


Screenshot, (*25)


Screenshot, (*26)


Screenshot, (*27)


Screenshot, (*28)


Screenshot, (*29)


Screenshot, (*30)


Screenshot, (*31)


Screenshot, (*32)


Screenshot, (*33)

The Versions

15/10 2017

dev-master

9999999-dev

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

15/10 2017

v1.2.6

1.2.6.0

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

23/04 2017

3.0.x-dev

3.0.9999999.9999999-dev

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

23/04 2017

v1.2.5

1.2.5.0

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

23/04 2017

v1.2.4

1.2.4.0

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

23/04 2017

v1.2.3

1.2.3.0

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

23/04 2017

v1.2.2

1.2.2.0

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

22/04 2017

v1.2.1

1.2.1.0

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

22/04 2017

v1.2.0

1.2.0.0

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

16/04 2017

v1.1.30

1.1.30.0

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

15/04 2017

v1.1.29

1.1.29.0

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

25/05 2016

1.0.x-dev

1.0.9999999.9999999-dev

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

25/05 2016

v1.1.28

1.1.28.0

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

04/10 2015

2.0.x-dev

2.0.9999999.9999999-dev

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

04/10 2015

v1.1.27

1.1.27.0

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

23/09 2015

v1.1.26

1.1.26.0

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

22/09 2015

v1.1.25

1.1.25.0

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

22/09 2015

v1.1.24

1.1.24.0

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

15/09 2015

v1.1.23

1.1.23.0

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

15/09 2015

v1.1.22

1.1.22.0

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

15/09 2015

v1.1.21

1.1.21.0

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

15/09 2015

v1.1.20

1.1.20.0

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

14/09 2015

v1.1.19

1.1.19.0

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

13/09 2015

v1.1.18

1.1.18.0

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

09/07 2015

v1.1.16

1.1.16.0

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

30/06 2015

v1.1.15

1.1.15.0

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

27/06 2015

v1.1.14

1.1.14.0

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

27/06 2015

v1.1.13

1.1.13.0

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

19/06 2015

v1.1.12

1.1.12.0

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

06/06 2015

v1.1.11

1.1.11.0

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

05/06 2015

v1.1.10

1.1.10.0

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

04/06 2015

v1.1.9

1.1.9.0

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

02/06 2015

v1.1.8

1.1.8.0

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

28/05 2015

v1.1.7

1.1.7.0

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

27/05 2015

v1.1.6

1.1.6.0

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

07/05 2015

v1.1.5

1.1.5.0

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

06/05 2015

v1.1.4

1.1.4.0

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

23/03 2015

v1.1.3

1.1.3.0

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

22/03 2015

v1.1.2

1.1.2.0

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

18/03 2015

v1.1.1

1.1.1.0

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

16/03 2015

v1.1

1.1.0.0

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

11/03 2015

v1.0.2

1.0.2.0

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

11/03 2015

v1.0.1

1.0.1.0

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler

11/03 2015

v1.0

1.0.0.0

Integrates PHP Debug Bar with Phalcon.

  Sources   Download

MIT

The Requires

 

by Avatar snowair

debug profiler phalcon debugbar webprofiler