Giter VIP home page Giter VIP logo

codeigniter-forensics's Introduction

Forensics for CodeIgniter

Forensics is a high-powered, completely customizable replacement for the CodeIgniter Profiler.

What's New?

Forensics adds a few things to the stock Profiler that should make your life as a developer a bit easier. At least when it comes to debugging.

  • The Profiler output is now completely skinnable. If you've read the comments in the Profiler class before, this is something that the EllisLab devs have said for a while it would be nice to do. Congrats. It's done.
  • The output now also includes a list of all files that your CodeIgniter app includes, as well as their location (relative to your FCPATH).
  • Output also has the ability to log items and track memory in your project via a new console class.
  • Any variables sent to the view are shown in the bar.
  • Forensics now provides a detailed look at queries run via Illuminate Database.

The default look, and some of the additional functionality, was heavily inspired by ParticleTree's PHP Quick Profiler.

Installing

Forensics is intended to be used as a Spark. However, it is best installed using Composer.

Create a composer.json file in your application's root (alongside the application and spark folders). Add the following text in the new file:

{
    "require": {
        "lonnieezell/codeigniter-forensics": "dev-master"
    }
}

Thanks to the magic of compwright/composer-installers the files are transferred to your application's third_party folder. In your application, you will first need to load the newly installed package. This is done easily through the autoloader, but could also be done in your controller with an environment check for maximum optimization.

$autoload['packages'] = array(APPPATH.'third_party/codeigniter-forensics');

Then, just enable the profiler like normal.

$this->output->enable_profiler(true);

Forensics Logging

In addition to the normal information that CI's Profiler provides, you now have two new logging commands at your disposal that work with the Forensics Profiler:

Console::log($data)

This function accepts any data type and simply creates a pretty, readable output of the variable, using print_r(). Very handy for logging where you are in the script execution, or outputting the contents of an array, or stdObject to your new 'console'.

Console::log_memory($variable, $name)

The log_memory function has two uses.

  1. When no parameters are passed in, it will record the current memory usage of your script. This is perfect for watching a loop and checking for memory leaks.

  2. If you pass in the $variable and $name parameters, will output the amount of memory that variable is using to the console.

In order to use either of these functions, you must be sure to load the Console library before you use it.

Illuminate Database Queries

In addition to CodeIgniter database queries, Forensics can display information about any queries run by Illuminate Database models or the Eloqeunt query builder. This feature is disabled by default. To enable this feature, change the config setting for eloquent in config/profiler.php. If you're using Illuminate Database in your project, note that this feature requires Capsule\Manager.

Other Tips

You can change the location of the profiler bar by changing the $bar_location variable at the top of the profiler_template view to one of the following locations:

  • top-right
  • top-left
  • bottom-left
  • bottom-right
  • top
  • bottom

codeigniter-forensics's People

Contributors

arclyte avatar brwnll avatar dianoga avatar lonnieezell avatar mckaygerhard avatar od3n avatar pocketarc avatar vtual 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

codeigniter-forensics's Issues

error using hmvc extension

Message: Undefined property: CI::$_ci_view_path

Filename: MX/Loader.php

Line Number: 275

Any thoughts on this?

improve README due lasted CI3 also be compatible with CI2

README only refers using composer, etc etc online tools, if user used CI2 (i have a folk of CI2 and also a CI3 folk) there's no clear instructions and usage structure..

ill' provide a clear structure and fresh README in new pull request, later, please if some opinions and notes about it, fil here before do the pull in following dais

Forensics Profiler not loaded if installed with Composer

I added "lonnieezell/codeigniter-forensics": "dev-master" and executed "composer update".
The package has been installed but the default profiler is loaded instead.

I have "include_once './vendor/autoload.php';" in main index.php. Isn't it enough to load codeigniter-forensics classes?

Could not find the language line ""

Line 289 of profiler_template.php

    <h2><?php echo lang('profiler_'. $section) ?></h2>

Needs to be replaced with

    <?php $append = ($section == 'get' || $section == 'post') ? '_data' : ''; ?>    
    <h2><?php echo lang('profiler_'. $section . $append) ?></h2>

Profiler not working on ajax call

How can i log db query on ajax call, $this->output->profiler(true) was displying db query on chrome developer tool when using default profiler which comes with ci.

Error in Profiler _compile_queries()

I noticed that the queries output seemed to be missing a bunch of queries that I knew should have been there. Checking the code I found that it was being put into an array like this:

$output[$time] = $val;

If the time is the same across queries the new query will overwrite previous values. In my case this led me to have 3 instead of 10 queries in the profiler output.

I modified the code in my branch to this:

$output[][$time] = $val;

And added an extra foreach loop in the output template.

I'd do a pull request but I've made a bunch of other changes here and there that would come along with it, but let me know if you want to know exactly what changes were made to fix this or check out my fork. In my local version I've also added a total value so it displays "Total Query Execution Time" at the bottom of the query list for a quick check on total query time.

ci_profiler_bar is not defined

I've just started getting a really strange error that I cant pin down. The actual bar works fine, but when clicking on any of the items, I get the following error in FF console:

ci_profiler_bar is not defined
onclick()1 (line 2)
event = click clientX=1179, clientY=573
[Break On This Error] ci_profiler_bar.show("ci-profiler-console", "ci-profiler-menu-console");

Support mutiple database instances

after a hard comparison between the two profiler addon for codeigniter, forensics are the better by so far! forensics handle and show many more date rether thatn others "complex addons"

if i have multi db instances in controller profiler forensics does not handle any db output, code example:

class Welcome extends CI_Controller
{
    public function index()
    {
        $this->DB1 = $this->load->database('development', TRUE);
        $this->DB2 = $this->load->database('development2', TRUE);

        $this->DB1->select('*');
        $result1 = $this->DB1->result();

        $this->DB2->select('*');
        $result2 = $this->DB2->result();
    }
}

there's some way to handle multi DB instances and show the querys, i try some patches backported from CI 3 brand but no success!

Not working on codeigniter 3.

I have setting all step you wrote.
I setting:
$autoload['packages'] = array(APPPATH.'third_party/codeigniter-forensics');

But it seem do not working.
I don't know why ?
Please help me.

call to undefined method fetch_class codeigniter 3

reading related:

bcit-ci/CodeIgniter#1303

In new CI3 was removed previously deprecated Routing Class <general/routing> methods fetch_directory(), fetch_class() and fetch_method() and now must be use the respective class properties instead.

now in CI3 must be:

CI_Router::fetch_class() (use CI_Router::$class instead)

the problem its to handle backguard compatibility with CI2 so i'm working on that

Error Warnings with $_GET vars

I have been getting errors when any $_GET variables are set

Severity: Notice
Message: Array to string conversion
Filename: libraries/Profiler.php
Line Number: 228

and

Severity: Warning
Message: Illegal string offset '$_GET['some_get_var']'
Filename: libraries/Profiler.php
Line Number: 235

Looking at the code it looks like $output sets itself as an array, and then tries to set it self as a string on line 228.

Problem handeling objects in usersession!

Forensics gives an error on line 440 of Profiler.php when a value is an object.. The following code fixes this:

if (is_object($val)) {
$output[$key] = json_encode($val);
} else {
$output[$key] = htmlspecialchars(stripslashes($val));
}

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.