fabfuel / prophiler Goto Github PK
View Code? Open in Web Editor NEWPHP Profiler & Developer Toolbar (built for Phalcon)
Home Page: http://prophiler.fabfuel.de
License: Other
PHP Profiler & Developer Toolbar (built for Phalcon)
Home Page: http://prophiler.fabfuel.de
License: Other
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?
$ 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.
I will rewrite it for myself, but please improve View\Simple support, or ability do disable registration of view in PluginManager
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?
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
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()?
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);
}]
After 'bar.
$logger->debug('Some debugging information', ['query' => ['user' => 12345], 'foo' => 'bar]);
Add generic data collector where which one can be named and hold any passed data.
Eg. for displaying configuration,
For applications like Rest API's, create persisted content to access profiler outside the app response, once this is not a HTML page.
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
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)
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?
Does it support Facebook's HHVM ?
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 :(
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
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)
]
);
}
}
...
Although quite trivial, <a href="javascript:void();">
is invalid syntax. It can be fixed by adding a 0 parameter like so: <a href="javascript:void(0);">
Anyway, nice library! ๐
I made mistake and have 1000 db queries on some page. I see 1000 queries, but cant found where it happens. Thank you
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
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.
There is:
$cache = \Fabfuel\Prophiler\Decorator\Phalcon\Cache\BackendDecorator($cacheBackend, $profiler);
There should be:
$cache = new \Fabfuel\Prophiler\Decorator\Phalcon\Cache\BackendDecorator($cacheBackend, $profiler);
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.
In demo page profiled fake queries.
How profile real queries?
if possible you can check whether $this->db is set or not
https://github.com/fabfuel/prophiler/blob/develop/src/Fabfuel/Prophiler/Plugin/Manager/Phalcon.php#L46
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.
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
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?
Hi All,
when I add fabuel/prophiler package. I have a problem. please preview image below:
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!What could be the problem?
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.
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%;
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; ?>
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.