Giter Site home page Giter Site logo

phalcon-debugbar's Introduction

Latest Stable Version Total Downloads Latest Unstable Version License

Phalcon Debugbar

Integrates PHP Debug Bar with Phalcon Framework.

中文说明

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

    php composer.phar require --dev snowair/phalcon-debugbar
    
  • update

    php composer.phar update snowair/phalcon-debugbar
    

Modify index.php

  1. Set your App Instance to DI:

    $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.

    (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.

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

Modify The ACL Code

Here is a example for INVO:

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.

For mongodb driver, You must install the mongodb extension and install the phplib : composer require mongodb/mongodb

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

About baseUri

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

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

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

    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:

(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:

  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:

// 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 /.

  • 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).

  • 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.

  • For any problems, you can open an Issue on Github.

Snapshots


Screenshot


Screenshot


Screenshot


Screenshot


Screenshot


Screenshot


Screenshot


Screenshot


Screenshot


Screenshot


Screenshot

phalcon-debugbar's People

Contributors

alexbusu avatar codelamer avatar dalt0n avatar fagai avatar jcmais avatar martinadi avatar orangetanguine avatar pauliusart21 avatar sergeyklay avatar sidroberts avatar surt avatar vsarikaya avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

phalcon-debugbar's Issues

debugbar autoloader

I have not seen how to load debugbar with Phalcon autoloader (registerDirs or registerNamespaces)
so I use composer autoloader.
This works, but is it the right solution?
The documentation says nothing about it.

What PSR specification is used?

Unable to get to work with simple service provider example

I can't get the bar to work with a simple service provider example. Actually it's not entirely based on simple service provider example, but its similar, just some folder structures changed. First I tried by creating a class called DebugBarServiceProvider like so:

<?php
namespace Bootstrap\Providers;
use Snowair\Debugbar\ServiceProvider as DebugBar;
use Snowair\Debugbar\Whoops\WhoopsServiceProvider as Whoops;
/**
 * \App\Providers\MvcDispatcherServiceProvider
 *
 * @package App\Providers
 */
class DebugBarServiceProvider extends AbstractServiceProvider
{
    /**
     * The Service name.
     * @var string
     */
    protected $serviceName = 'debugBar';

    /**
     * Register application service.
     *
     * @return void
     */
    public function register()
    {
        error_reporting(E_ALL);
        $this->di->setShared($this->serviceName, function () {
                $debugBar = new DebugBar();
                $debugBar->start();
                new Whoops($this->di);
                return $debugBar;
            }
        );
    }
}

I have a boostrap class like that and I make sure the DI and application is setted before the debug bar

<?php
namespace Bootstrap;
use Phalcon\Config;
use Phalcon\Di;
use Phalcon\Di\FactoryDefault;
use Phalcon\DiInterface;
use Phalcon\Mvc\Application;
use Bootstrap\Providers\ServiceProviderInterface;
use Bootstrap\Providers\EventManagerServiceProvider as EventManager;
use Bootstrap\Providers\DebugBarServiceProvider;
use Snowair\Debugbar\ServiceProvider as DebugBar;
use Snowair\Debugbar\Whoops\WhoopsServiceProvider as Whoops;

class BootstrapApplication
{
    /**
     * The Dependency Injector.
     * @var DiInterface
     */
    protected $di;

    /**
     * The Service Providers.
     * @var ServiceProviderInterface[]
     */
    protected $serviceProviders = [];
    
    /**
     * The Application.
     * @var Application
     */
    protected $app;
    /**
     * Bootstrap constructor.
     *
     * @param $appPath
     */
    public function __construct(Config $config=null)
    {
        $this->di = new FactoryDefault();
        Di::setDefault($this->di);
        $this->di->setShared('bootstrapApp', $this);
        if($config)  $this->di->setShared("config", $config);
        $providers = include APP_PATH . '/config/providers.php';
        $application = new Application($this->di);
        $this->di->setShared("app", $application);
        if($config->application->mode == "developtment") {
            $this->initializeService(new DebugBarServiceProvider($this->di));
        } elseif($config->application->mode == "maintenance") {
            header("location: assets/html/maintenance.html");
            exit;
        }
        if (is_array($providers)) {
            $this->initializeServices($providers);
        }
        if(!array_key_exists("eventsManager", $this->di)) {
            $this->initializeService(new EventManager($this->di));
            $application->setEventsManager($this->di->getShared("eventsManager"));
        }
        $this->app = $application;
    }

    /**
     * Gets the Dependency Injector.
     *
     * @return Di
     */
    public function getDi()
    {
        return $this->di;
    }


    public function getContent($pathInfo=null)
    {
        return $this->handle($pathInfo)->getContent();
    }

     /**
     * Runs the Application
     *
     * @return string
     */
    public function run($pathInfo=null)
    {
        echo $this->handle($pathInfo)->getContent();
    }

    public function runAndSend($pathInfo=null)
    {
        $this->handle($pathInfo)->send();
    }

    public function handle($pathInfo=null)
    {
        return $this->app->handle($pathInfo);
    }

    /**
     * Initialize Services in the Dependency Injector Container.
     *
     * @param string[] $providers
     */
    protected function initializeServices(array $providers)
    {
        foreach ($providers as $name => $class) {
            if(!$class instanceof DebugBarServiceProvider) {
                $this->initializeService(new $class($this->di));
            }
        }
    }

    /**
     * Initialize the Service in the Dependency Injector Container.
     *
     * @param ServiceProviderInterface $serviceProvider
     *
     * @return $this
     */
    protected function initializeService(ServiceProviderInterface $serviceProvider)
    {
        $serviceProvider->register();
        $this->serviceProviders[$serviceProvider->getName()] = $serviceProvider;
    }
}

My issue is that nothing happens and I included the Whoops and also don't work. I setted multiple providers and most of them are the same of simple service provider, except Database and MvcDispatcherServiceProvider. After trying to initialize the debug bar as a service provider I tried to initialize directly on BootstrapApplication class and I get the following error:

Uncaught Error: Call to a member function detachAll() on null in vendor\snowair\phalcon-debugbar\src\Whoops\WhoopsServiceProvider.php:36

So I removed the Whoops temporarilly and my baseUri it's messed up. I defined a UrlServiceProvider just link simple servide provider, and my baseUri it's resolve to something like: http://mydomain.com/idr_report/, but using debugbar my uri is now public/.

I also tried to use de config/debugbar.php withou success. I checked everything else I just don't work for me. Below my environtment settings:

  • PHP 7.1.5
  • Phalcon 3.3.2
  • IIS 8.5
  • Windows Server 2012

Just to be clear past to use the debugbar I was using Whoops and everything was working fine.

doesn't work

phalcon 3.4, php 7.1, clean install:

PHP Fatal error: Default value for parameters with a class type hint can only be NULL in ...../vendor/symfony/var-dumper/Dumper/CliDumper.php on line 61

No issue

Not reporting any issues (yet). I just wanted to say that this is great! I have tried out fabfuel/prophiler in the past, but with my setup it doesn't work. It crashes the browser and even the server, but Phalcon Debugbar is perfect! I didn't know about it until today, and I had thrown together my own profiling bar for my current project, but your is a lot better!

Thanks

Activating collectors

i have added following line in public/index.php but nothing effected. What is the proper way to add collectors.

$di['debugbar']->addCollector(new Snowair\Debugbar\DataCollector\PhalconRequestCollector);

Problems loading _debugbar resources, add slash before url.

Hi,
I have a problem with debugbar, It try to get some resources adding a full domain name in the request and slash before, and then repeat the domain:

http://domain.com/http://domain.com/_debugbar/assets/stylesheets?m=backend&1506001644".

Anybody knows how can I solve it?

Thanks
Fidel

existence of the configuration file : no verification

if we specify a configuration file, and the file does not exist at this location...

(new ServiceProvider( APP_PATH .'/app/config/debugbar.php'))->start();

No warning message is displayed, and the default configuration is used, which can be ambiguous

Get 502 Bad Gateway when AJAX Request

Phalcon version: 1.3.6
Php version : 5.5.19

echo json_encode($users->toArray());

When we return the json format as response to Ajax, it will occur error 502: Bad Gateway.
If we disable the phalcon-debugbar, everything is fine.

I also tested it in phalcon version 2.0.2, but it was fine.

No timeline

others tab are okay, but Timeline tab is always empty? whats wrong?

screen shot 1394-09-13 at 9 24 20 pm

Warning: get_class() expects parameter 1 to be object

With PHP7.0.30, we have a warning bug :
( ! ) Warning: get_class() expects parameter 1 to be object, null given in /usr/share/nginx/html/projectname/vendor/snowair/phalcon-debugbar/src/DataCollector/RouteCollector.php on line 59

Bug Line :
$result['Controller'] = get_class( $controller_instance = $dispatcher->getActiveController());

Fix :
$result['Controller'] = $dispatcher->getActiveController() != null ? get_class( $controller_instance = $dispatcher->getActiveController()) : $controller_instance ="";

Thks !

2.0.1使用Phalcon/Mvc/View/Simple报错

Catchable fatal error: Argument 2 passed to Snowair\Debugbar\DataCollector\ViewCollector::__construct() must implement interface Phalcon\Mvc\ViewInterface, instance of Phalcon\Mvc\View\Simple given, called in /home/wangyu/phalcon/library/phalcon-debugbar/src/PhalconDebugbar.php on line 368 and defined in /home/wangyu/phalcon/library/phalcon-debugbar/src/DataCollector/ViewCollector.php on line 26

No query, cache etc. tabs

Hi,
For some reason can't find these tabs.
Messages, exceptions, timeline, request tabs are shown. And pushing texts are working like charm.

I use Phalcon 2.1.0 Beta 2, but also tried downgrade to 2.0.3 and was same issue.

collectors

doctrine = true

Fatal error: Class 'Doctrine\DBAL\Logging\DebugStack' not found in /Users/huangjinlong/developer/projects/phalcon_demo/vendor/snowair/phalcon-debugbar/src/PhalconDebugbar.php on line 230

FontAwesome issue

Hi.

Cool plugin!

Find issue when font-awesome style is not loaded on site then icons is missing.

In file Resources/font-awesome/style.css
Looks like font-family must be PhpDebugbarFontAwesome instead FontAwesome

With this fix icons is visible.

404 error for static files

I use default INVO with your plug-in, but receive errors:

"NetworkError: 404 Not Found - http://test.loc/_debugbar/assets/stylesheets?1445286912"
stylesh...5286912
"NetworkError: 404 Not Found - http://test.loc/_debugbar/assets/javascript?1445286912"
javascr...5286912
"NetworkError: 404 Not Found - http://test.loc/_debugbar/assets/stylesheets?1445286912"
stylesh...5286912
"NetworkError: 404 Not Found - http://test.loc/_debugbar/assets/javascript?1445286912"

my public.index.php

<?php
error_reporting(E_ALL);

use Phalcon\Mvc\Application;
use Phalcon\Config\Adapter\Ini as ConfigIni;

try {
    define('APP_PATH', realpath('..') . '/');

    $config = new ConfigIni(APP_PATH . 'app/config/config.ini');
    if (is_readable(APP_PATH . 'app/config/config.ini.dev')) {
        $override = new ConfigIni(APP_PATH . 'app/config/config.ini.dev');
        $config->merge($override);
    }
    require APP_PATH . 'app/config/loader.php';
    require APP_PATH . 'app/config/services.php';

    $application = new Application($di);
    $di['app'] = $application;
    (new Snowair\Debugbar\ServiceProvider())->start();

    echo $application->handle()->getContent();
} catch (Exception $e){
    echo $e->getMessage() . '<br>';
    echo '<pre>' . $e->getTraceAsString() . '</pre>';
}

my app/confing/loader.php

<?php
require_once __DIR__ . '/../../vendor/autoload.php';
$loader = new \Phalcon\Loader();
$loader->registerDirs(
    array(
        APP_PATH . $config->application->controllersDir,
        APP_PATH . $config->application->pluginsDir,
        APP_PATH . $config->application->libraryDir,
        APP_PATH . $config->application->modelsDir,
        APP_PATH . $config->application->formsDir,
    )
)->register();

Any ideas?

Exception: The argument is not initialized or iterable()

Hi,

I was triying to setup the debugbar with the Phalcon 2.0 release, it throws a
Exception: The argument is not initialized or iterable() phalcon/http/response/headers.zep (98)

Can't find the error line that throws the exception from debugbar, it appears to be after the
$debugbar->modifyResponse($response); but can't follow it after that.

Variables values not showing up

I even found how to fix it:

$variables = $this->_db->getSqlVariables();
instead of
return $sql;
in Phalcon/Db/Profiler.php getRealSql (98)

TemplatesWidget Error

When i set config collectors "view" to true, i get a PhpDebugBar.Widgets.TemplatesWidget is not a constructor

I can't find the right solution

Exception when enable cache module

Hi,

Firstly, I want to thank You for great module, it's really helpful :)

But I got a little error, I enabled cache module and got exception:

Phalcon\Di\Exception: Call to undefined method or service 'createProxy' 
/vagrant/www/vendor/snowair/phalcon-debugbar/src/PhalconDebugbar.php (265)

My configuration of cache DI is:

$di->setShared('cache', function () {
$cache = new Multiple([
    $this->get('redis'),
]);

return $cache;
});


$di->setShared('redis', function () {
$frontCache = new DataFrontend([
    'lifetime' => 3600 * 24 * 7
]);

$redis = new \Phalcon\Cache\Backend\Redis($frontCache, [
    'host' => $this->get('config')->redis->host,
    'port' => $this->get('config')->redis->port,
    'auth' => $this->get('config')->redis->password,
    'statsKey' => '_PHCR'
]);

return $redis;
});

What is wrong?

Using doctrine with Phalcon and phalcon-debugbar

Hi,

I'm creating a Phalcon project, but instead of using Phalcon's native database access I'm using doctrine, since I'm more comfortable with the data-mapper pattern rather than the active record one.

Anyway, I'm using your awesome phalcon-debugbar but I'm not able to see database information.

I went to the original PHP Debug Bar documentation to look for a solution, but it doesn't seem to work.

What I did was, following the mentioned docs and your instructions, to insert this lines of code in my bootstrap:

        $application = new Phalcon\Mvc\Application($di);
        // CONFIGURE DEBUGBAR
        $di['app'] = $application;
        (new ServiceProvider(APP_PATH . 'config/debugbar.php'))->start();
        $em = $di->get('entityManager');
        $debugStack = new DebugStack();
        $em->getConnection()->getConfiguration()->setSQLLogger($debugStack);
        $debugbar = $di->get('debugbar');
        $debugbar->addCollector(new DoctrineCollector($debugStack));
        echo $application->handle()->getContent();

Is there any way that I can manage to see the database tab using doctrine in Phalcon?

Thanks for the awesome job, and thanks in advance for your help

Class 'Phalcon\Mvc\Vendor\Snowair\Debugbar\ServiceProvider' not found

Hi, when I try to put your debug bar into my project, the class of Snowair is not found. This is the error:
Class 'Phalcon\Mvc\Vendor\Snowair\Debugbar\ServiceProvider' not found in C:\xampp\htdocs\phalcon_coolmod\public\index.php on line 29
I am using Phalcon 2.0.10
My index.php:
`<?php

error_reporting(E_ALL);

define('APP_PATH', realpath('..'));

try {

/**
 * Read the configuration
 */
$config = include APP_PATH . "/app/config/config.php";

/**
 * Read auto-loader
 */
include APP_PATH . "/app/config/loader.php";

/**
 * Read services
 */
include APP_PATH . "/app/config/services.php";

/**
 * Handle the request
 */
$application = new \Phalcon\Mvc\Application($di);
$di['app'] = $application; //  Important
(new \Snowair\Debugbar\ServiceProvider())->start();

echo $application->handle()->getContent();

} catch (\Exception $e) {

}
`

I donwloaded it with composer, and is in app/vendor/snowair

[SOLUTION] Warning: Illegal offset type in /vendor/snowair/phalcon-debugbar/src/PhalconDebugbar.php on line 419 / 432

Hi
A new bug and the solution.
For this warning : Warning: Illegal offset type in /vendor/snowair/phalcon-debugbar/src/PhalconDebugbar.php on line 419 replace line 419

$templates[$viewFilePath]['startTime'] = microtime(true);

with

if(is_array($viewFilePath)){
                foreach($viewFilePath as $infos_path){
                    $templates[$infos_path]['startTime'] = microtime(true);
                }
}else{
 $templates[$viewFilePath]['startTime'] = microtime(true);
}

Do the same line 432 (line 441 after previous change)

See you

Error Phalcon 4

Anyone can help ? I'm using phalcon 4 but i got error like below
i'm using dev-master branch

[18-Nov-2020 10:07:26 Asia/Jakarta] PHP Notice: Undefined index: path in /home/derry/mysite/vendor/snowair/phalcon-debugbar/src/ServiceProvider.php on line 204
[18-Nov-2020 10:07:26 Asia/Jakarta] PHP Stack trace:
[18-Nov-2020 10:07:26 Asia/Jakarta] PHP 1. {main}() /home/derry/mysite/public/index.php:0
[18-Nov-2020 10:07:26 Asia/Jakarta] PHP 2. require() /home/derry/mysite/public/index.php:3
[18-Nov-2020 10:07:26 Asia/Jakarta] PHP 3. Snowair\Debugbar\ServiceProvider->start() /home/derry/mysite/app/bootstrap_web.php:63
[18-Nov-2020 10:07:26 Asia/Jakarta] PHP 4. Snowair\Debugbar\ServiceProvider->boot() /home/derry/mysite/vendor/snowair/phalcon-debugbar/src/ServiceProvider.php:35
[18-Nov-2020 10:07:26 Asia/Jakarta] PHP 5. Snowair\Debugbar\ServiceProvider->safeCheck() /home/derry/mysite/vendor/snowair/phalcon-debugbar/src/ServiceProvider.php:163
[18-Nov-2020 10:07:26 Asia/Jakarta] PHP Warning: require(): Filename cannot be empty in /home/derry/mysite/vendor/snowair/phalcon-debugbar/src/ServiceProvider.php on line 204
[18-Nov-2020 10:07:26 Asia/Jakarta] PHP Stack trace:
[18-Nov-2020 10:07:26 Asia/Jakarta] PHP 1. {main}() /home/derry/mysite/public/index.php:0
[18-Nov-2020 10:07:26 Asia/Jakarta] PHP 2. require() /home/derry/mysite/public/index.php:3
[18-Nov-2020 10:07:26 Asia/Jakarta] PHP 3. Snowair\Debugbar\ServiceProvider->start() /home/derry/mysite/app/bootstrap_web.php:63
[18-Nov-2020 10:07:26 Asia/Jakarta] PHP 4. Snowair\Debugbar\ServiceProvider->boot() /home/derry/mysite/vendor/snowair/phalcon-debugbar/src/ServiceProvider.php:35
[18-Nov-2020 10:07:26 Asia/Jakarta] PHP 5. Snowair\Debugbar\ServiceProvider->safeCheck() /home/derry/mysite/vendor/snowair/phalcon-debugbar/src/ServiceProvider.php:163
[18-Nov-2020 10:07:26 Asia/Jakarta] PHP Fatal error: require(): Failed opening required '' (include_path='.:/opt/php72/lib/php') in /home/derry/mysite/vendor/snowair/phalcon-debugbar/src/ServiceProvider.php on line 204
[18-Nov-2020 10:07:26 Asia/Jakarta] PHP Stack trace:
[18-Nov-2020 10:07:26 Asia/Jakarta] PHP 1. {main}() /home/derry/mysite/public/index.php:0
[18-Nov-2020 10:07:26 Asia/Jakarta] PHP 2. require() /home/derry/mysite/public/index.php:3
[18-Nov-2020 10:07:26 Asia/Jakarta] PHP 3. Snowair\Debugbar\ServiceProvider->start() /home/derry/mysite/app/bootstrap_web.php:63
[18-Nov-2020 10:07:26 Asia/Jakarta] PHP 4. Snowair\Debugbar\ServiceProvider->boot() /home/derry/mysite/vendor/snowair/phalcon-debugbar/src/ServiceProvider.php:35
[18-Nov-2020 10:07:26 Asia/Jakarta] PHP 5. Snowair\Debugbar\ServiceProvider->safeCheck() /home/derry/mysite/vendor/snowair/phalcon-debugbar/src/ServiceProvider.php:163

Magic findFirstBy methods do not work when they return null

When the query does not return anything, findFirstByX fails with "method 'findFirstByX' does not exist on model 'Foo'".

This is why (phalcon/mvc/model.zep:4036):

        let records = self::_invokeFinder(method, arguments);
        if records !== null {
            return records;
        }

_invokeFinder returns null both when the method name is invalid and when it is valid but actually returns null. IMO we should use exceptions here instead.

EDIT: or just return false from _invokeFinder instead?

issue with yonaCMS integration.

Hi, I tried to implement this into yonaCMS and unfortunately is working only if I add echo $application->handle()->getContent(); instead $dispatcher->dispatch(); Please check below link to make an idea about $dispatcher->dispatch();

https://github.com/oleksandr-torosh/yona-cms/blob/master/app/Bootstrap.php

Thank you!

Call to undefined method App\Middleware\Url::getStatic()

i have problem with this library

see my ss
image

code of Url

<?php
namespace App\Middleware;

/*
|--------------------------------------------------------------------------
| Database Provider
|--------------------------------------------------------------------------
|
| This value is the name of your application. This value is used when the
| framework needs to place the application's name in a notification or
| any other location as required by the application or its packages.
*/

use \Phalcon\Mvc\Url as PhalconUrl;
use \Phalcon\Mvc\User\Component;

class Url extends Component
{
	/**
	 * Url Instance
	 *
	 */
	protected static $url;

	/**
	 * Define base url
	 *
	 */
	function __construct()
	{
		$config 	= $this->di['config']->app;
		$url 		= new PhalconUrl;

		$url->setBaseUri($config->base_url);

		self::$url = $url;
	}

	/**
	 * Base Url
	 *
	 */
	public static function get($path = '', $args = null, $local = true)
	{
		return self::$url->get($path, $args, $local);
	}

	/**
	 * Asset Url
	 *
	 */
	public static function asset($path = '', $args = null, $local = true)
	{
		return self::$url->get('public/' . $path, $args, $local);
	}
	
}

thanks

Debugbar messages not working

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}

[SOLUTION] Phalcon 4.1.0 - \Profiler::startProfile() must be of the type string, null given

Hi !
A new bug with the new version of Phalcon (4.1.0).
You can have this error :

Fatal error: Uncaught TypeError: Argument 1 passed to Snowair\Debugbar\Phalcon\Db\Profiler::startProfile() must be of the type string, null given, called in /data/www/project.com/vendor/snowair/phalcon-debugbar/src/PhalconDebugbar.php on line 710 and defined in /data/www/project.com/vendor/snowair/phalcon-debugbar/src/Phalcon/Db/Profiler.php on line 70

You can read the reason in the changelog of phalcon :
https://github.com/phalcon/cphalcon/blob/master/resources/CHANGELOG-4.1.md
Changed Phalcon\Db\Adapter\*::getRealSQLStatement() to return the full SQL query with parameters #12196

SOLUTION :
/vendor/snowair/phalcon-debugbar/src/PhalconDebugbar.php on line 706 change

 $sql = $db->getRealSQLStatement();

to

$sql = $db->getSQLStatement();

And it works ;-)

See you !

Static url on subdomain

Hi.

I have problem with using debugbar, when i have set "url static" on other (sub) domain.

Earlier, I used a static url within the same domain (statics were in the "/cdn/" folder). In order for assets and open handler to be read correctly, I redirected everything containing _debugbar to "baseUrl + /_debugbar*" and it worked.

My prev uri settings look this:
baseUrl: / staticsUrl: /cdn/

After changing the url of the statics to the subdomain, debugbar generates addresses to the resources in the following way:
http://domain/http://cdn.domain/_debugbar/assets/stylesheets?m=1544445135&module (or http://domain/cdn.domain/ if i not set protocol in address)

My uri settings after changing to subdomain:
baseUrl: / staticsUrl: //cdn.domain/

Ok. In this moment, assets (js and css) loaded success, because everything after _debugbar is redirected to the base address (domain/ debugbar*_). It follows from this that for assets, the address is built in the following way:
src/JsRender.php

 $baseuri = rtrim($this->url->getBasePath(),'/').'/';
    $html .= sprintf(
        '<link rel="stylesheet" type="text/css" href="%s?m='.$m.'&%s">' . "\n",
        $baseuri.ltrim($this->url->getStatic(array('for'=>'debugbar.assets.css')),'/'),
        $time
    );

src/PhalconDebugbar.php
Unfortunately, the address "open handler" is created directly from statics::

$openHandlerUrl = $this->di['url']->getStatic( array('for'=>'debugbar.openhandler') );

and resulting in the creation of a non-existent address to an external domain resource statics:
http://cdn.domain/_debugbar/open?op=get&id=xxxxxxxxxxxxxxxxxxxxxxxx

Since the resources for debugbar are generated by the controller, would not it be better to read them directly from url->get instead of url->getStatic?
Is it not a mistake to read open handler from an address intended for static, or should the address to it be generated in the same way as in the case of assets?

Can I expect the next version, uri configuration options for debugbar?

PHP Debugbar is not working

Hi All,
Sorry, My English is not good.
I have add phalcon-debugbar from this link: https://github.com/snowair/phalcon-debugbar.
but it is not working.
When I run, In my console is display:
2015-10-20_162412
I found error:
dashboard:449 GET http://dashboard.somo.local_debugbar/assets/stylesheets?1445331526 net::ERR_NAME_NOT_RESOLVED
dashboard:450 GET http://dashboard.somo.local_debugbar/assets/javascript?1445331525 net::ERR_NAME_NOT_RESOLVED
dashboard:453 Uncaught ReferenceError: PhpDebugBar is not defined(anonymous function) @ dashboard:453
sb-admin-2.js:2 Uncaught TypeError: $ is not a function

How to I can fix it ?

Ajax display message

i want to see a message from ajax request.
In ajax request i set a message or info to display in debugbar but it will not appeare.

how i can do that?

In debug bar I can't see ajax request.

Thanks in advantage

phalcon-module-skeleton integration

hello,

can you help me with "how to" integrade your debugger into this application, since it's started in a different way

https://github.com/ovr/phalcon-module-skeleton

i get hte fllowing error:

Fatal error: Uncaught exception 'Phalcon\Di\Exception' with message 'A dependency injection object is required to access the application services' in phalcon/di/injectable.zep:127

Uncaught Error: Access to undeclared static property

Randomly I'm getting this error in _debugbar/assets/javascript file (Chrome console error "Uncaught SyntaxError"):


Fatal error: Uncaught Error: Access to undeclared static property: Phalcon\Di::$_default in ...

I'm using unmodified Vokuro boilerplate and PHP 7.0.8.

Incorrect asset URI rendered

Since commit 95efd03 phalcon-debugbar always renders root asset URIs (ie. /_debugbar/assets...) instead of using the application baseUri.

This disallows using phalcon-debugbar on any application that is not hosted at the root of its domain.

Contrary to what the commit message seems to indicate, it did work perfectly before. IMO it should be reverted, I think @bluetec had a configuration issue that had nothing to do with phalcon-debugbar itself.

_debugbar/assets/javascript?m=frontend&1523208358

my javascript url : http://192.168.0.10/_debugbar/assets/javascript?m=frontend&1523208358

Notice: Undefined index: path in /andydata/wwwroot/video/video_new/vendor/snowair/phalcon-debugbar/src/ServiceProvider.php on line 203

Warning: require(): Filename cannot be empty in /andydata/wwwroot/video/video_new/vendor/snowair/phalcon-debugbar/src/ServiceProvider.php on line 203

Fatal error: require(): Failed opening required '' (include_path='.:/andydata/server/php/lib/php') in /andydata/wwwroot/video/video_new/vendor/snowair/phalcon-debugbar/src/ServiceProvider.php on line 203

HTML Minify

Phalcon debugbar is not working when i minify the HTML with the code below.

//Handle the request
$output = $application->handle()->getContent();

// HTML Minification
if ( $appConfig->html_minify ) {
    ob_start( function() use ($output) {
        $search = array( '/\>[^\S ]+/s', '/[^\S ]+\</s', '/(\s)+/s' );
        $replace = array( '>', '<', '\\1' );
        $buffer = preg_replace($search, $replace, $output);
        return $buffer;
    });
}

echo $output;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.