Giter Site home page Giter Site logo

fabfuel / prophiler Goto Github PK

View Code? Open in Web Editor NEW
444.0 43.0 53.0 2.3 MB

PHP Profiler & Developer Toolbar (built for Phalcon)

Home Page: http://prophiler.fabfuel.de

License: Other

PHP 89.09% CSS 3.61% Ruby 0.41% HTML 6.84% Shell 0.06%
php developer-toolbar toolbar phalcon php-profiler benchmark profile

prophiler's People

Contributors

bryant1410 avatar cyberbln avatar fabfuel avatar kscr-rocket avatar lajosbencz avatar mdular avatar ogarbe avatar potfur avatar scrutinizer-auto-fixer avatar shochdoerfer 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

prophiler's Issues

how to trace timeline on phalcon?

Hi, i cant view nothing on timeline :(
i put in my index.php:

include APP_PATH . 'vendor/autoload.php';

$profiler = new \Fabfuel\Prophiler\Profiler();

and the end of file:
after:
echo $application->handle()->getContent();

i put:

$toolbar = new \Fabfuel\Prophiler\Toolbar($profiler);
$toolbar->addDataCollector(new \Fabfuel\Prophiler\DataCollector\Request());
echo $toolbar->render();

too:

$di = new FactoryDefault();
$di->setShared('profiler', $profiler);

i dont know where put:

 $pluginManager = new \Fabfuel\Prophiler\Plugin\Manager\Phalcon($profiler);
 $pluginManager->register();

at the end of my index.php too?

Help!, what I'm missing?

PHP 7 not supported?

$ composer require fabfuel/prophiler
Using version ^1.5 for fabfuel/prophiler
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for fabfuel/prophiler ^1.5 -> satisfiable by fabfuel/prophiler[1.5.0].
    - fabfuel/prophiler 1.5.0 requires php ~5.4 -> your PHP version (7.0.0RC7) or "config.platform.php" value does not satisfy that requirement.

Phalcon\View\Simple support

I will rewrite it for myself, but please improve View\Simple support, or ability do disable registration of view in PluginManager

Toolbar position

Hi guys!
It would be awesome to have an opportunity to customize toolbar position (at least bottom and top). And don't you think that bottom as default position is better than top position?

Vegas CMF integration

Hello,

First: thanks for the library - that's a really nice piece of work!

Before your toolbar was released I once prepared a simple profiling library for Vegas CMF. As your implementation is more flexible, I've been thinking about dropping our solution and integrating Prophiler into.
What do you think of such connection?

Best regards,
Radek

Hash link should preventDefault

Hi, nice work on this toolbar! One thing that bothers me is that switching between tabs changes URL and adds # to it. It should preventDefault()?

Unable to load timeline

Hey,
I'm using Phalcon Framework 2.1.0 BETA 2, with a multi-module application.
When I enable the plugin manager I get an error (it works without the timeline..)..

Any ideas why this happens? :)

Phalcon\Mvc\Dispatcher\Exception: SessionController handler class cannot be loaded

0 Phalcon\Mvc\Dispatcher->_throwDispatchException(SessionController handler class cannot be loaded, 2)

1 Phalcon\Dispatcher->dispatch()

2 Phalcon\Mvc\Application->handle()

My index.php code is:

$profiler = new \Fabfuel\Prophiler\Profiler();
$di->set('profiler', $profiler, true);

$toolbar = new \Fabfuel\Prophiler\Toolbar($profiler);
$toolbar->addDataCollector(new \Fabfuel\Prophiler\DataCollector\Request());
$pluginManager = new \Fabfuel\Prophiler\Plugin\Manager\Phalcon($profiler);
$pluginManager->register();

//register modules here..

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

On another configuration file (loaded before the profiler):

if(DEBUG) {
    $di->set('dispatcher', function () use ($di) {
        $dispatcher = new \Phalcon\Mvc\Dispatcher();
        $dispatcher->setEventsManager($di->get('eventsManager'));
        return $dispatcher;
    }, true);
}]

Add quote, on demo page

After 'bar.
$logger->debug('Some debugging information', ['query' => ['user' => 12345], 'foo' => 'bar]);

Add generic data collector

Add generic data collector where which one can be named and hold any passed data.
Eg. for displaying configuration,

Acess profiler outside response

For applications like Rest API's, create persisted content to access profiler outside the app response, once this is not a HTML page.

PSR Logger Interface cannot be found

I just came across with this issue, any idea?

Fatal error: Interface 'Psr\Log\LoggerInterface' not found in /var/www/clients/client2/web4/web/app/services/Fabfuel/Prophiler/Adapter/Psr/Log/Logger.php on line 12

Official PSR-7 and PSR-15 support

Would be nice to have official PSR-7 Request DataCollector, and PSR-15 middleware for integration.

I am aware of the already existing package (https://github.com/bitExpert/prophiler-psr7-middleware), but would be nice to have it OOTB, also the middleware is not PSR-15 compatible.

If you like the idea, I would be happy to work on a few PRs.

(I opened this PR because as far as I can see you have no problem with supporting third-party within this package)

Fantastic but I have issues

I'm building an application that is built on mruz base-app version 1.3 (https://github.com/mruz/base-app/releases) with Phalcon 1.3.4.

I have tried Prophiler on a simple Phalcon app, and it seems to work fine, although I couldn't get anything displaying on time line.

The problem is on my app (based on mruz base-app) is that Prophiler results in really slow page loads. I have my app running on a vagrant box, and during page load, with Prophiler added, the CPU will some times max out. While the page displays ok, if I view the page source, it seems it is repeating or looping. The page source and HTML for prophiler is repeated over and over. Very strange, and unfortunately it makes Prophiler unusable for me on this project.

Any idea what the problem might be and how I can fix it?

Fix probably need for css

Hi,

When queries are logged it is not possible to see the full queries. It would be nice if there is a way to see the queries that are big. See screenshot .

screenshot from 2016-01-15 23-06-03

See the 3rd one looks truncated due to styling issue.

Css prefix because not replaceable

I must to edit my styles to support your toolbar
.section
.header
.row
.table

I use it too on my old website.

Needs to be prefixed :(

Is it possible to see an array detail in log

Hello,

I would like to debug the content of an array.
I tried

$logger->debug($my_array);

But all I can see is "array". If I add print_r, nothing is readable anymore.
Is there a way ?

Cheers

PDO Profiling

Hi,

First of all great tool you wrote and thanks.
I've recently updated prophiler on my existing codebase from 1.1 to 2.0 and tried to apply PDO profiling.
Since i heavily use prepared statements in my project i noticed the PDO profiling breaking pretty fast since it was relying on PHP::PDO and not on Phalcon\Db\Adapter\Pdo (ie: tableExists is implicitly called).

Is there a reason PHP::PDO is required instead of Phalcon's extension?

I've modified the code locally (which i can fork and PR) to work with prepared statements.

Here's an excerpt from my code which causes the following exception:

PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback, class 'PDO' does not have a method 'tableexists' in ~\libraries\fabfuel\prophiler\src\Fabfuel\Prophiler\Decorator\PDO\PDO.php on line 45

# services.php
...
$di['db'] = function () use ($di) {
    $mode = require __DIR__.'/mode.php';
    $dbFilePath = __DIR__."/database-{$mode}.php";

    if (is_file($dbFilePath)) {
        $dbconfig = require_once $dbFilePath;
        // Slightly altered to get PDO statement with existing config
        $db = new DbAdapter($dbconfig->database->toArray());
        $dbhandler = $db->getInternalHandler();

        return new \Fabfuel\Prophiler\Decorator\PDO\PDO(
            // new DbAdapter($dbconfig->database->toArray()),
            $dbhandler, // object(PDO)
            $di->get('profiler')
        );
    } else {
        throw new Exception("Unable to find database configuration.");
    }
};
...
# router.php
...
            // Split URI into parts for quering the database
            preg_match('~/*([\w\d-_]+)~iu', $router->getRewriteUri(), $matches);

            if (!empty($matches[1])) {
                @list($uri, $uriIndex) = explode('-', $matches[1]);

                // Lookup route in the databse
                $route = self::findFirst([
                    'conditions' => 'uri = ?1 AND uri_index = ?2',
                    'bind' => [1 => $uri, 2 => (int) (!empty($uriIndex)) ? $uriIndex : 0],
                ]);

                if ($route) {
                    // Match! Add route to router
                    $router->add(
                        $router->getRewriteUri(),
                        [
                            'module' => $route->module,
                            'controller' => $route->controller,
                            'action' => $route->action,
                            'params' => unserialize($route->params)
                        ]
                    );
                }
            }
...

Need little help in implementing

Hi,
I am in learning phase and wanted to test it out on sample App https://github.com/phalcon/vokuro .
Can you advice where and what to add so that can see queries, cache and user details too, right now only showing REQUEST and General which you have added by default.

It will really help to get better understanding of phalcon in general.

Thanks

Add ability to display HTML as panel content

I'd like to use this toolbar as unified interface to display all necessary debug information related to my project. Sometimes I need to display a lot of information which have complex structure. It would be good if I would have ability to render my own markup and display it in one of the tabs.

Small error in README.md

There is:

$cache = \Fabfuel\Prophiler\Decorator\Phalcon\Cache\BackendDecorator($cacheBackend, $profiler);

There should be:

$cache = new \Fabfuel\Prophiler\Decorator\Phalcon\Cache\BackendDecorator($cacheBackend, $profiler);

How does it work with MongoDB

Hi fabuel,

I'm using Phalcon 2.0+ and i can't add profiler for my MongoDB database
This is my config in services.php

/**
 * The FactoryDefault Dependency Injector automatically register the right services providing a full stack framework
 */
$di = new FactoryDefault();

/**
 * Phalcon profiler
 */
$di->setShared('profiler', function () use ($di, $config) {

    //if (isset($config->profiler) && (bool)$config->profiler->profiler === true) {
    return new \Fabfuel\Prophiler\Profiler();
    //}
    // return null;
});

.....

$di->set('db', function () use ($config) {
    return new DbAdapter($config->database->toArray());
});

$di->set('mongo', function () use ($config) {
    $conn = sprintf('mongodb://%s:%s@%s:%s', $config->mongodb->username, $config->mongodb->password, $config->mongodb->host, $config->mongodb->port);
    $mongo = new \MongoClient($conn);
    return $mongo->selectDb($config->mongodb->dbname);
});

$di->set('collectionManager', function () {
    return new Phalcon\Mvc\Collection\Manager();
});

..................

/**
 * Set profiler event handler
 */
$profiler = $di->get('profiler');
//if (!empty($profiler)) {
$profiler->addAggregator(new \Fabfuel\Prophiler\Aggregator\Database\QueryAggregator());
$profiler->addAggregator(new \Fabfuel\Prophiler\Aggregator\Cache\CacheAggregator());
$pluginManager = new \Fabfuel\Prophiler\Plugin\Manager\Phalcon($profiler);
$pluginManager->register();
//}

and here is my index.php

<?php

error_reporting(E_ALL & ~E_STRICT);

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

try {

    /*
     * Composer autoloader
     */
    require APP_PATH . "/vendor/autoload.php";

    /**
     * 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);

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

    /**
     * Add Phalcon profiler toolbar
     */
    //if ($di->get('profiler') !== null) {
    session_commit();
    $toolbar = new \Fabfuel\Prophiler\Toolbar($di->get('profiler'));
    $toolbar->addDataCollector(new \Fabfuel\Prophiler\DataCollector\Request());
    echo $toolbar->render();
    //}

} catch (\Exception $e) {
    throw $e;
    echo $e->getMessage();
}

I spent 2 days and can't figure it out, please help me, thanks.

How use Session and Application?

How i understood you don't give something sources to repo?
On demo page on timeline, we see Application and Session Component.

I write new Class in Plugin\Phalcon\Mvc\ApplicationPlugin.php and implement appropriate method (events).
It's work fine, but i don't want implement all listeners :) If they exist by default.

Regards.

Don't add output to all my pages [fixed]

I have a html request and API (JSON) request in the same application, the main problem is the project add a output string to all my request, including JSON.

The solution for this inconvenience is disable Views in que API controller in initialize and check on the main page (index.php) if the View is disabled.

Simple App template "Index.php":

$toolbar = new \Fabfuel\Prophiler\Toolbar($profiler);
$toolbar->addDataCollector(new \Fabfuel\Prophiler\DataCollector\Request());

if(!$di['view']->isDisabled()){
echo $toolbar->render();
}

I hope this can help more people with the same problem

Fatal error

i add in my index.php,
at top:

require_once(APP_PATH.'vendor/autoload.php');
$profiler = new \Fabfuel\Prophiler\Profiler();

and the bottom:

$toolbar = new \Fabfuel\Prophiler\Toolbar($profiler);
$toolbar->addDataCollector(new \Fabfuel\Prophiler\DataCollector\Request());
echo $toolbar->render();

But fatal error show:

Fatal error: Interface 'Psr\Log\LoggerInterface' not found in /var/www/feedback/vendor/fabfuel/prophiler/src/Fabfuel/Prophiler/Adapter/Psr/Log/Logger.php on line 12
Help?

how to add fabfuel/prophiler package to phalcon php

Hi All,
when I add fabuel/prophiler package. I have a problem. please preview image below:
2015-10-06_150000

this is my index.php:

handle()->getContent(); ``` } catch (\Exception $e) { echo $e->getMessage(); } $profiler = new \Fabfuel\Prophiler\Profiler(); $toolbar = new \Fabfuel\Prophiler\Toolbar($profiler); $toolbar->addDataCollector(new \Fabfuel\Prophiler\DataCollector\Request()); echo $toolbar->render(); In config.php I add row: 'debugbar' => APP_PATH . '/vendor/', In loader.php I add row: $config->application->debugbar, it is that all. Help please!

Missing Mongo ProfileInterface

Hi, I am trying this out for Phalcon/MongoDB profiling. However, I am getting this error:
image

I saw in your unit test that it should have fabfuel/mongo dependency but that seems missing in your repositories. Is there any alternative for this?

Ignore composer.lock

Can I ask why composer.lock is version controlled? There are voices on both sides, but there are more voices saying it shouldn't be. Causes problems in packages when people work with different PHP versions, etc.

CSS: Logs

When we toggle debug, notice, alert ..

If content contain more than 4 rows, content will be placed beyond "div".

decision:
display: inline-block; width: 100%;

round() in css styles.

Hi,

There is a problem with using round() in css styles to get a rounded value for instance 10.50%. This works great if You set php locale to en_US. Then round uses "dot" as a separator. But for instance in locale PL_pl round uses "coma ," as decimal seperator ...

To fix this use number_format(round(), 2, '.', '') to ensure a dot separator is used in float numbers.

View/partials/timeline/benchmark.phtml

<div class="timeline">
    <div class="benchmark <?= $benchmark->getColorClass() ?>"
         style="
             min-width: <?= number_format($benchmark->getWidth(), 2, '.', '') ?>%;
             width: <?= number_format($benchmark->getWidth(), 2, '.', '') ?>%;
             left: <?= number_format($benchmark->getOffset(), 2, '.', '') ?>%"
         title="<?= $benchmark->getName() ?>"></div>
</div>

View/partials/timeline/scale.phtml

<?php for ($t = 0; $t <= $durationScale; $t += $scale): ?>
        <div class="marker" style="left: <?= number_format(round(($t/$durationScale)*100, 3), 3, '.', '') ?>%;">
            <div class="label"><?= $t ?> ms</div>
            <div class="line"></div>
        </div>
    <?php endfor; ?>

Profiler dont work when using Phalcon\Mvc\View\Simple

I try render piece of my code with Phalcon\Mvc\View\Simple.
Like this

$view = new \Phalcon\Mvc\View\Simple();
$view->setDI($di);
$view->setViewsDir($viewsDir);
$view->registerEngines(static::registerEngines($view, $di));
$render = $view->render($path, $params);

and get error


Fatal error: Uncaught TypeError: Argument 2 passed to Fabfuel\Prophiler\Plugin\Phalcon\Mvc\ViewPlugin::beforeRenderView() must implement interface Phalcon\Mvc\ViewInterface, instance of Phalcon\Mvc\View\Simple 
given in Z:\OpenServer\domains\project\server\trunk\vendor\fabfuel\prophiler\src\Fabfuel\Prophiler\Plugin\Phalcon\Mvc\ViewPlugin.php:42 
Stack trace: 
#0 [internal function]: Fabfuel\Prophiler\Plugin\Phalcon\Mvc\ViewPlugin->beforeRenderView(Object(Phalcon\Events\Event), Object(Phalcon\Mvc\View\Simple), 'Z:\\OpenServer\\d...') 
#1 [internal function]: Phalcon\Events\Manager->fireQueue(Object(SplPriorityQueue), Object(Phalcon\Events\Event)) 
#2 [internal function]: Phalcon\Events\Manager->fire('view:beforeRend...', Object(Phalcon\Mvc\View\Simple), 'Z:\\OpenServer\\d...') 
#3 [internal function]: Phalcon\Mvc\View\Simple->_internalRender('user_groups/mod...', Array) 
#4 Z:\OpenServer\domains\project\server\trunk\app\core\Helpers\ViewHelper.php(60): Phalcon\Mvc\View\Simple->render('user_groups/mod...', Array) 
#5 Z:\OpenServer\ in Z:\OpenServer\domains\project\server\trunk\vendor\fabfuel\prophiler\src\Fabfuel\Prophiler\Plugin\Phalcon\Mvc\ViewPlugin.php on line 42

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.