Dans World

Improve Your jQuery Knowledge with the Source Viewer @sitepoint recommendation

jQuery source viewerjQuery is a great JavaScript framework. However, as with any library, sometimes it’s necessary to get under the hood to discover what’s going on. Perhaps it’s because you’re tracing a bug or are just curious about how jQuery achieves a particular UI effect.

Although jQuery compresses to under 70Kb, the uncompressed file comprises of 6,000 lines of JavaScript code. Your text editor or IDE may offer a function list, but there are dozens of methods to wade through and it’s not always easy to find the code block you need. Fortunately, UK web developer James Padolsey has come up with a neat solution — the jQuery source viewer.

jQuery source viewer

The tool will find the code for any function name you enter (note that names are case-sensitive). By default, it will return version 1.4 code, but versions 1.3.2 and 1.2.6 are also available.

Other jQuery methods are highlighted and click-able so it’s easy to jump to other code blocks. You can also find functions from the URL, e.g.

The tool’s a fantastic idea and will certainly save time when hunting through the jQuery source. Thanks James. My only request: a case-insensitive auto-suggest box would make it absolutely perfect.

great idea, and one that will help out a lot while coding.

Filed under  //   debugging PHP   jquery   web development  

Peacock Suit » Zend framework: Logging Database Queries to FireBug

Logging database queries to FireBug is sinfully simple with the new component Zend_Db_Profiler_Firebug in ZF 1.6, now available, you can download it here Zend Framework Download Page.

Requirements:

  1. Firefox Browser ideally version 3 but version 2 is also supported.
  2. Firebug Firefox Extension.
  3. FirePHP Firefox Extension.

More information on requirements at the Zend Framework Documentation -  Profiling with Firebug

Let’s look at some examples.

< ?php
// Instatiate the database
$db = Zend_Db::factory('Pdo_Mysql',
    array(
        'host' => 'localhost',
        'dbname' => 'zf_feature_testing',
        'username' => 'user123',
        'password' => 'pass123'
    )
);
 
// Instantiate the profiler in your bootstrap file 
$profiler = new Zend_Db_Profiler_Firebug('All Database Queries:');
// Enable it
$profiler->setEnabled(true);
// Attach the profiler to your db adapter 
$db->setProfiler($profiler);
 
// Run your queries
$result1 = $db->fetchAll('SELECT * FROM zf_test');
$result2 = $db->fetchAll('SELECT * FROM zf_test where id = ?', 3);

Alternatively you can add the profiler parameters to the Zend_Db factory.

< ?php
// Instatiate the database, passing in the profiler parameters.
$db = Zend_Db::factory('Pdo_Mysql',
    array(
        'host' => 'localhost',
        'dbname' => 'zf_feature_testing',
        'username' => 'user123',
        'password' => 'pass123',
        'profiler' => array(
            'enabled' => true,
            'class' => 'Zend_Db_Profiler_Firebug'
        )
    )
);

Or from an .ini file using Zend_Config_Ini

$config = new Zend_Config_Ini('../application/config.ini', 'development');
$db = Zend_Db::factory($config->database);

config.ini

[development]
database.adapter                    = pdo_mysql
database.params.host                = localhost
database.params.username            = user123
database.params.password            = pass123
database.params.dbname              = zf_feature_testing
database.params.profiler.enabled    = true
database.params.profiler.class      = Zend_Db_Profiler_Firebug

Show me my profiling data?

Open FireBug, you will see a link under console.

Profiling with FireBug

Click it open and it will list all the queries that were run.

Profiling with FireBug

Enjoy!

just found out that the zend framework has a built in component to allow me to use firePHP, ive always wondered how to go about setting this add on up and using it to debug my work and now here it is, thanks @sitepointdotcom for the initial post talking about using firePHP http://www.sitepoint.com/blogs/2010/02/09/debug-php-firebug-firephp/

Filed under  //   debugging PHP   firePHP   PHP development   sitepoint articles   zend framework