php: debugger, profiler and more

Post on 01-Sep-2014

6.252 Views

Category:

Technology

3 Downloads

Preview:

Click to see full reader

DESCRIPTION

Slide introduce about the process of debugging and profling a web application. How to use PHPED debugger to debug your application and Xdebug to profile your application.

TRANSCRIPT

PHP Debugger, Profiler & more

Vo Duy Tuan – <tuanmaster2002@yahoo.com>Bloghoctap.com

Coding is not enough!

$Table_of_contents

IDEs for Web Developer

Debugging

Profiling

Load Testing

Tài trợ:

Learn about IDE.

IDEs for Web Developer1

1.1. What is an IDE?

Integrated Development Environment

Application for software development

Common Features: Syntax highlight Autocomplete File Explorer Collapse/Expand

1.2. Common IDEs for Web Developer

Notepad, Notepad++ Adobe Dreamweaver Aptana Komodo PhpEd Zend Studio PHP Designer …

1.3. Recommend Features for PHP IDE

Built-in parser

Documentor

Debugger

DB Client

Text Format

1.4. Small Quizz

What is the difference between 2 screenshots?

IDE for PHP, support HTML, CSS Paid Software, current version: 5.9 Main Features:

Debugger Autocomplete DB Client Documentor Code Explorer Exclude folders, files in project.

1.5. NuSphere PhpEd Introduction

1.6. NuSphere PhpEd screenshot

Learn how to use PhpEd Debugger to debug your web applications.

Debugging2

What is debug?

Find errors in your code.

How to debug?

Output with HTML: echo(), print_r(), var_dump()

Store debug information: File, Database

Live debug: PhpEd Debugger

2.1. Debug Introduction

Integrate with Firefox (DBGbar addon)

Step debugging

Multi breakpoint

Watch runtime variables

Watch call stack

Remote debugging

2.2. PhpEd Debugger features

2.3. PhpEd Debugger Installation

Step 1: Install php extension

Step 2: Install DBGbar addon for Firefox

Step 3: Update PHP.INI config

Restart your web server (if needed)

Step 1: Install PHP Extension

Go to ‘C:\..\nusphere\phped\debugger\server\’ Select correct library for your platform and PHP version Copy file (.dll on Windows) to php extension folder

Step 2: Install DBGbar addon

In Firefox, go to menu Tools >> Add-ons Search ‘DBGbar’ and install. Restart Firefox, you will get DBGbar toolbar:

Step 3: Update PHP.INI config

Add dbg extension to extension list: extension=dbg-php-5.2.dll

Add configuration for debugger [debugger] debugger.enabled=on debugger.profiler_enabled=on debugger.hosts_allow=localhost apple.comdebugger.hosts_deny=ALL debugger.ports=7869, 10000/16

2.4. PhpEd Debugger usage

2.5. DEMO Debugging

Learn how to use Xdebug extension to find bottleneck and increase performance for your web applications.

Profiling3

3.1. Profiling Introduction

Find bottleneck Make application run faste

3.2. Two ways of profiling

Built-in profiler 3rd-party profiler

3.2.1. Built-in profiler

Tracking code embed in your PHP code Example: Using timer start & stop

3.2.1. Built-in profiler…cont.

3.2.2. 3rd-party profiler

Install new extension Do not change your PHP code More Information Famous Library: Xdebug

3.3. Xdebug Installation

Step 1: Install php extension

Step 2: Update PHP.INI config

Restart your server (if needed)

Step 1: Install php extension

Download correct extension for your platform & PHP version

Can go to ‘http://www.xdebug.org/find-binary.php’ to find correct Xdebug file for your system from phpinfo() output

Copy file (.dll on Windows) to php extension folder

Step 2: Update PHP.INI config

Add configuration for xdebug:[xdebug]zend_extension_ts = C:\AppServ\php5\ext\php_xdebug-2.1.0-5.2-vc6.dll

xdebug.profiler_output_dir = "C:\xdebug"xdebug.profiler_output_name = "callgrind.%R.%t"xdebug.profiler_enable = 0xdebug.profiler_append=0xdebug.profiler_enable_trigger = 1xdebug.extended_info=1

3.4. Xdebug Usage

Step 1: Generate cachegrind file Base on xdebug config in PHP.INI to create

cachegrind file.

For above php.ini config: Add parameter XDEBUG_PROFILE to your request string will create cachegrind file. Examp;e: Normal : http://bloghoctap.com Profiler: http://bloghoctap.com?XDEBUG_PROFILE

2.4. Xdebug Usage…

Step 2: View & analyze your profile result: WinCacheGrind Kcachegrind

2.4.1. WinCacheGrind Viewer

2.4.2. Kcachegrind Viewer

3.5. DEMO Profiling

Benchmark your web application.

Load Testing4

4.1. ApacheBench

4.2. Apache jMeter

…Võ Duy Tuấn…tuanmaster2002@yahoo.com…Web Freelancer… PHP Trainer…http://blogHoctap.com

you_forgotIf

It’s time to query …

Thanks you!

top related