GithubHelp home page GithubHelp logo

loic-sharma / profiler Goto Github PK

View Code? Open in Web Editor NEW
174.0 14.0 23.0 461 KB

A PHP 5.3 profiler based off of Laravel 3's Anbu.

License: BSD 2-Clause "Simplified" License

CSS 26.58% JavaScript 14.87% PHP 58.55%

profiler's Introduction

Profiler

A PHP 5.3 profiler based off of Laravel 3's Anbu. NOTE: this project is no longer being maintained. Please use Barry's debug bar instead.

Installation

Installing profiler is simple. First, you'll need to add the package to the require attribute of your composer.json file.

{
    "require": {
        "loic-sharma/profiler": "1.1.*"
    },
}

Installing Using Laravel 4

To enable te profiler in Laravel 4 you will need to register the Service Provider and the Facade.

  1. Add 'Profiler\ProfilerServiceProvider', to the list of service providers in app/config/app.php
  2. Add 'Profiler' => 'Profiler\Facades\Profiler', to the list of class aliases in app/config/app.php
  3. In console run php artisan config:publish loic-sharma/profiler

And voila! You can use the profiler.

Profiler::startTimer('testLogging');

// The profiler listens to Laravel's logger.
Log::info('Hello World!');
Log::notice('Some event occured.');

Profiler::endTimer('testLogging');

Installing For Your Own Project

Add the following to your code:

$logger = new Profiler\Logger\Logger;
$profiler = new Profiler\Profiler($logger);

You can now use the profiler to your heart's content.

$profiler->startTimer('testLogging');

$logger->debug($object);
$logger->info('Hello World!');
$logger->notice('Some event occurred.');
$logger->warning('Careful: some warning.');
$logger->error('Runtime error.');
$logger->critical('This needs to be fixed now!');
$logger->emergency('The website is down right now.');

$profiler->endTimer('testLogging');

echo $profiler;

Copyright and License

Profiler was written by Loic Sharma. Profiler is released under the 2-clause BSD License. See the LICENSE file for details.

Copyright 2012 Loic Sharma

profiler's People

Contributors

loic-sharma avatar barryvdh avatar briankiewel avatar syphernl avatar radmen avatar franzliedke avatar ltsochev-dev avatar lordcoste avatar

Stargazers

Amir Hosseinzadeh avatar Mostafa avatar Thomas Quiroga avatar Lawal Akanbi avatar Yogi Prasetyawan avatar Cristian Echeverri avatar Bengi avatar Marcio Vale avatar Murshed Ahmmad Khan avatar Mayank Baluni avatar Alex Varganov avatar BahaaNoah avatar Luuk Hoeben avatar Andrea Sangiorgio avatar  avatar  avatar Angus H. avatar  avatar Paul Denisevich avatar Alessio Delmonti avatar Kunal Varma avatar Rowen avatar Pantelis Koukousoulas avatar Nick avatar Ciaran Downey avatar Kevin Colten avatar Omar Bahareth avatar Piyush Chauhan avatar Martin B avatar  avatar  avatar Cody avatar Roy avatar Deryk Wenaus avatar Cătălin G avatar 老小王 avatar Bruno P. Kinoshita avatar Summer avatar  avatar Bora Yalcin avatar Gian Crescini Santillan avatar Mr. Hsu avatar Dawid Makowski avatar Elias Rodrigues avatar Kirill Nesmeyanov avatar 孙立杰 avatar Pooyan Khosravi avatar Bruno Wego avatar Ahmad avatar Milan avatar 风起 avatar Michael Corbett avatar Augustus D'Souza avatar Bryan Berger avatar Marcelo Canina avatar Jorge González avatar Victor Teixeira avatar Danny Dinges avatar Bipin Upadhyay avatar Chris avatar  avatar  avatar Ferri Sutanto avatar George Barba avatar Igor Sirkovich avatar Milos Levacic avatar Salahuddin Hairai avatar Simon Bennett avatar Emily Saforrian avatar Can Geliş avatar Kamal Nasser avatar John Kenn avatar Irfaq Syed avatar Nathan Isaac avatar quickgreen avatar kutunesirka avatar Jonathan Devine avatar  avatar Jared Linwood avatar YGZX avatar Jim Wardlaw avatar Henry Juan avatar Yasmina Savic avatar  avatar Bo-Yi Wu avatar Travis van der F. avatar Djordje Kovacevic avatar Sidney Widmer avatar  avatar Tony R Quilkey avatar Ger Hobbelt avatar Sam Evaskitas avatar hansim avatar Chris De David avatar  Tomek Sułkowski avatar Thomas Welton avatar Marko Mestrovic avatar Bram Devries avatar Ireneusz Kuliga avatar  avatar

Watchers

[0] avatar Jens Kleikamp avatar Max Castro avatar Elias Rodrigues avatar Osvaldo Brignoni avatar  avatar James Cloos avatar Andrej B. avatar 姚文强 avatar Rafael Crispim Ignácio avatar Nathan Isaac avatar Mostafa El Bakly avatar  avatar  avatar

profiler's Issues

strrpos() expects parameter 1 to be string, array given

ErrorException
…/­vendor/­loic-sharma/­profiler/­src/­Profiler/­ProfilerServiceProvider.php

Line 190

if(($pos = strrpos($responseContent, '')) !== false)
{

We're using Cartalyst's API package to return the response, which means the $responseContent could be an internal PHP value rather than your assumed string.

Caching Included Files causing error when files changed

I encountered error when adding changing file at the global.php

Tried to composer dump-autoload and fixing everything .

Just found out its Profiler error because the IncludedFiles cached are not updated
to the latest one.

Way to fix it to restart web server which I think quite weird.

I think Profiler mostly used in dev/staging env, which means theres no need to cache the included files, or somehow make it auto clean cache after composer dump-autoload as most of the time the change are somehow change the file/folder structure.

Show included files

It would be nice to show how many files are included to handle the request and when opened a list of the size/files.

Listen for app logging

IMHO it does not make much sense to be using a custom profiler logger, it would be way better if the profiler would listen for the app's central logging and display its output on the log tab.

Multiple database problem

Hi, I have installed profiler on a laravel 4 test installation with 2 databases (mysql the default one and sqlsrv on a remote machine) and everything works fine, but when try to execute a query with an eloquent model linked at the second database the system gives me the whoops page with this error:

SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: NO)

because it tries to open the default connection in spite of I have setted the connection property of the model to 'sqlsrv'. If I uninstall profiler everything works fine.

Fatal error when running the example

I get this error when running the example:

Fatal error: Class 'Profiler\Logger\LogLevel' not found in C:\path-to-my-project\vendor\loic-sharma\profiler\src\Profiler\Logger\Logger.php on line 50

$profiler = new \Profiler\Profiler(new \Profiler\Logger\Logger);
$profiler->startTimer('testLogging');
$profiler->log->debug(new \stdClass);
$profiler->log->info('Hello World!');
$profiler->log->notice('Some event occurred.');
$profiler->log->warning('Careful: some warning.');
$profiler->log->error('Runtime error.');
$profiler->log->critical('This needs to be fixed now!');
$profiler->log->emergency('The website is down right now.');
$profiler->endTimer('testLogging');
die((string)$profiler);

Docs: how to configure it in Laravel 4 to be the same as in Laravel 3

It would be nice if it was written in the docs how I can make / configure this profiler in Laravel 4 to work (almost) the same way it works in Laravel 3. There I just set a configuration variable and I get it in the browser. At the moment I don't know exactly, where should I write what code for it to be available on every page and show me SQLs and the same stuff that the profiler in Laravel 3 did.

Do not display on json/xhr requests

When the response is JSON, the profiler shouldn't be added.
Also, XHR request shouldn't add the profiler (data requested from ajax)

Maybe add an check before adding the profiler?

How do you use it, what should it output?

Just installed on Laravel 4 and added service provider and facade to app config.

With...

Profiler::startTimer('testLogging');
Log::info('Loop start');
Log::info('Loop end');
Profiler::endTimer('testLogging');

...I get only the usual log entries. No timer benchmark data?

Profile is now enabled by default

PR #17 changed the default behavior. Previously, the profiler would listen to the app.debug value (or a possible app.profiler), but now you set the default value in your config.

$app['config']->get('profiler::enabled', $app['config']->get('app.debug')); will always return true/false, because you have set the variable.

It would make more sense (imho) to comment that value out by default, and correctly use the debug value. If you want to override it, just publish the config and uncomment that line.

The change you made now, will make all websites running the profiler show the profiler in production profiles after their first composer update..

Profiler closes

When you click on any of the tabs it opens and the closes, it's not possible to open the extra info in a "normal" way.

I'm using Chrome Version 28.0.1500.11 dev-m and I tried Firefox 19.0.1 too.

Looks like the problem is it's calling the open and close function one after another.

Any way to disable profiler without setting debug to false?

I'm using Laravel 4 and if I understand the docs correctly, I should set 'debug' => false to disable the profiler? But most of the time, working on my development machine, I don't want to see the profiler (I just want to use it some times to check performance), but I'd still like to be able to see the debug errors. Is this possible?

Example logging is not showing up in the profiler.

Laravel 4, example code below. "testLogging" timer shows up, and Log::xxxx('whatever') shows up in the logs, but not in the profiler.

Is there something more to this that I am missing?

Profiler::startTimer('testLogging');

// The profiler listens to Laravel's logger.
Log::info('Hello World!');
Log::notice('Some event occured.');

Profiler::endTimer('testLogging');

Logs display overflow-x

profiler

This is what my profiler looks like. The thing that bugs me are the horizontal scroll bars. If I just remove the overflow-x: auto statement for the .anbu pre element, they disappear and everything works.

Unable to see logs in profiler

Hi
I've added a couple of test logs in a controller to test the profiler:

Log::info('Message 1');
Log::notice('Message 2');

I can see the entries in the text log file but I dont see any entries in the log section of the profiler view.

I'm using latest version. Installed as prescribed and can see Sql logs etc in view but no log entries. Have I missed something?

Profiler code is rendered before HTML

My application uses Blade for the template & views. Using
Route::after(function() { echo Profiler::render(); }); adds in the profiler code on top of everything else which means its before the HTML/head etc tags.

With the original Laravel integrated Anbu the content is placed on the bottom. This is not 100% optimal either (since you should not have stuff outside of the html scope) but works better since it does not appear to conflicting with the site's CSS where this method is.

Is there any way of getting the output appended instead of preprended (without having to place it in the template)

turn off for json ?

I am calling a post route and get back json, unfortunatley i also get in my response the complete data
Is there anyway of disabling it the call ?

Expand the time tab

Is it possible to narrow down the "Time" option to see what is adding component is making the total time go sky high? :)

Move route after filter to boot() method.

You're currently creating your after filter inside the register() method.

Resolving objects from the container (as you do here for the router) should always be done in boot() or in some type of callback, so that other packages have the chance to either use Container::extend() or Container::resolving() on these objects.

Profiler breaks artisan migration

It seems profiler is breaking artisan migration:refresh command, and possibly some other commands. Whenever I prompt php artisan migration or any of migration commands, it gives me the following error:

[ErrorException]
Notice: Use of undefined constant LARAVEL_START - assumed 'LARAVEL_START' in C:\Raphael\...\vendor\loic-sharma\profiler\src\Profiler\ProfilerServiceProvider.php line 29

If I comment Profiler's Provider out, it works.

Memory leak on DB insert / update etc.

Profiler is causing a memory leak for certain Fluent / Eloquent queries.

First I thought it was a laravel issue, but disabling the profiler, solved the leak.

See here:
laravel/framework#1641

I couldn't locate the cause of this leak yet, probably some logging.

Viewing SQL Statement

Hello,

How do I tell the profiler to show the SQL query in the SQL tap when using the profiler in a custom project?

include __DIR__ . '/vendor/autoload.php';

$logger = new Profiler\Logger\Logger;
$profiler = new Profiler\Profiler($logger);

$profiler->startTimer('query');
try {
    $query = "SELECT * FROM users WHERE id = ?";

    $id = '21';

    $stmt = $db->prepare($query);
    $stmt->bindValue(1,$id);
    $stmt->execute();
} catch (Exception $e) {
    $logger->error('Can not query database.');
}

$results = $stmt->fetchAll(PDO::FETCH_ASSOC);

$logger->debug($results);

$profiler->endTimer('query');

echo $profiler;

When I run this the profiler displays everything except for the SQL statement.

image

Is there something special i need to do in order for the profiler to show the SQL statment?

Thanks.

Composer unable to download Profiler

I tried updating my package through composer, after my last issue was fixed, but it isn't really working. First it asked for my github account, and now it's just giving me an error:

[Composer\Downloader\TransportException]
The "https://api.github.com/repos/loic-sharma/profiler/zipball/v1.0.2" file could not be downloaded (HTTP/1.1 404 Not Found)

If I change my dependency on composer.json to 1.0.1 it correctly downloads the last version.

Wrong total time when queries take longer than 1000ms

The times in the query log are number formatted:

protected function getElapsedTime($start)
{
    return number_format((microtime(true) - $start) * 1000, 2);
}

Because of this, the calculation of total time is wrong when queries take longer than 1000ms.

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.