php: debugger, profiler and more

37
PHP Debugger, Profiler & more Vo Duy Tuan – <[email protected]> loghoctap.com Coding is not enough!

Upload: vo-duy-tuan

Post on 01-Sep-2014

6.252 views

Category:

Technology


3 download

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

Page 1: PHP: Debugger, Profiler and more

PHP Debugger, Profiler & more

Vo Duy Tuan – <[email protected]>Bloghoctap.com

Coding is not enough!

Page 2: PHP: Debugger, Profiler and more

$Table_of_contents

IDEs for Web Developer

Debugging

Profiling

Load Testing

Tài trợ:

Page 3: PHP: Debugger, Profiler and more

Learn about IDE.

IDEs for Web Developer1

Page 4: PHP: Debugger, Profiler and more

1.1. What is an IDE?

Integrated Development Environment

Application for software development

Common Features: Syntax highlight Autocomplete File Explorer Collapse/Expand

Page 5: PHP: Debugger, Profiler and more

1.2. Common IDEs for Web Developer

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

Page 6: PHP: Debugger, Profiler and more

1.3. Recommend Features for PHP IDE

Built-in parser

Documentor

Debugger

DB Client

Text Format

Page 7: PHP: Debugger, Profiler and more

1.4. Small Quizz

What is the difference between 2 screenshots?

Page 8: PHP: Debugger, Profiler and more

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

Page 9: PHP: Debugger, Profiler and more

1.6. NuSphere PhpEd screenshot

Page 10: PHP: Debugger, Profiler and more

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

Debugging2

Page 11: PHP: Debugger, Profiler and more

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

Page 12: PHP: Debugger, Profiler and more

Integrate with Firefox (DBGbar addon)

Step debugging

Multi breakpoint

Watch runtime variables

Watch call stack

Remote debugging

2.2. PhpEd Debugger features

Page 13: PHP: Debugger, Profiler and more

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)

Page 14: PHP: Debugger, Profiler and more

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

Page 15: PHP: Debugger, Profiler and more

Step 2: Install DBGbar addon

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

Page 16: PHP: Debugger, Profiler and more

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

Page 17: PHP: Debugger, Profiler and more

2.4. PhpEd Debugger usage

Page 18: PHP: Debugger, Profiler and more

2.5. DEMO Debugging

Page 19: PHP: Debugger, Profiler and more

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

Profiling3

Page 20: PHP: Debugger, Profiler and more

3.1. Profiling Introduction

Find bottleneck Make application run faste

Page 21: PHP: Debugger, Profiler and more

3.2. Two ways of profiling

Built-in profiler 3rd-party profiler

Page 22: PHP: Debugger, Profiler and more

3.2.1. Built-in profiler

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

Page 23: PHP: Debugger, Profiler and more

3.2.1. Built-in profiler…cont.

Page 24: PHP: Debugger, Profiler and more

3.2.2. 3rd-party profiler

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

Page 25: PHP: Debugger, Profiler and more

3.3. Xdebug Installation

Step 1: Install php extension

Step 2: Update PHP.INI config

Restart your server (if needed)

Page 26: PHP: Debugger, Profiler and more

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

Page 27: PHP: Debugger, Profiler and more

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

Page 28: PHP: Debugger, Profiler and more

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

Page 29: PHP: Debugger, Profiler and more

2.4. Xdebug Usage…

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

Page 30: PHP: Debugger, Profiler and more

2.4.1. WinCacheGrind Viewer

Page 31: PHP: Debugger, Profiler and more

2.4.2. Kcachegrind Viewer

Page 32: PHP: Debugger, Profiler and more

3.5. DEMO Profiling

Page 33: PHP: Debugger, Profiler and more

Benchmark your web application.

Load Testing4

Page 34: PHP: Debugger, Profiler and more

4.1. ApacheBench

Page 35: PHP: Debugger, Profiler and more

4.2. Apache jMeter

Page 36: PHP: Debugger, Profiler and more

…Võ Duy Tuấn…[email protected]…Web Freelancer… PHP Trainer…http://blogHoctap.com

you_forgotIf

Page 37: PHP: Debugger, Profiler and more

It’s time to query …

Thanks you!