Wednesday, August 4, 2010
NetBeans and Xdebug
Client:
Operating System: Windows 7 Enterprise [version: 6.1.7600 ]
Administrator privileges: No
Product Version: NetBeans IDE 6.9 (Build 201006101454)
Java: 1.6.0_21; Java HotSpot(TM) Client VM 17.0-b16
Server:
nginx/0.7.67 - not relevant
Apache/2.2.13 (Unix) with mod_php - not relevant
PHP 5.2.13 (cli) (built: Jul 21 2010 14:56:47)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans
Steps:
Install Xdebug via PEAR. I got version 2.1.0.
Enable Xdebug extension in php.ini:
zend_extension = /usr/local/lib/php/extensions/no-debug-non-zts-20060613/xdebug.so ; <=- can be different
xdebug.remote_enable = on
xdebug.remote_handler = dbgp
xdebug.remote_host = 2.1.1.11 ; <=- your client ip here
xdebug.remote_port = 9000
xdebug.remote_mode = req
xdebug.idekey = "netbeans-xdebug" ; <=- default netbeans id
xdebug.remote_log = /path/to/your/logs/xdebug.log
xdebug.extended_info = 1
Check installation in CLI:
php -m | grep xdebug
php -i | grep xdebug
Restart Apache.
Check firewall settings that "C:\Program Files\NetBeans 6.9\bin\netbeans.exe" is allowed in proper network locations.
Open NetBeans. Go to your project properties > Run Configuration.
Setup "Project URL" and other if need.
Open "Advanced..." settings, check everything there.
I was able to run into debug mode but without execution line highlight.
So I got back to advanced settings of the project, setup path mapping.
Example:
/usr/local/lib/php/Zend > C:\tmp\ZendFramework-1.10.7-minimal\library\Zend
After that, I saw that Zend files were mapped successfully, but part of project files on network storage not. You can see that in a "Call Stack" window.
It turns out, that NetBeans don't likes network in debug mode.
To fix that, open "My Computer" > "Map network drive" to some letter.
Now, use the new drive for path mapping instead of direct network path.
And voila - it works! ;-)
Notes:
By default NetBeans will break on the first line of the script (you can change this behavior in the PHP / General section of the NetBeans Preferences).
Sources:
NetBeans wiki - HowToConfigureXDebug
Path Mapping In PHP Debugger
PHP 5.3 + XDebug + NetBeans + Mac OSX Leopard
See also:
Xdebug - Debugging with multiple users
Be careful with "Ask Every Time" debug URL
Update:
Upgrade to NetBeans 6.9.1 that fixes double ask for debug URL and other improvements.
Wednesday, February 24, 2010
PHP
sudo pecl install PDO_MYSQL
The problem was that after configure, make can't find mysql header files.
...
In file included from /tmp/pear/temp/PDO_MYSQL/pdo_mysql.c:31:
/tmp/pear/temp/PDO_MYSQL/php_pdo_mysql_int.h:25:19: mysql.h: No such file or directory
In file included from /tmp/pear/temp/PDO_MYSQL/pdo_mysql.c:31:
/tmp/pear/temp/PDO_MYSQL/php_pdo_mysql_int.h:36: error: syntax error before "MYSQL"
...
So I learned how to make an extension manually.
I ran locate mysql.h, copyed all mysql headers from there to current folder and now you can make it
phpize --clean
phpize
./configure
make
make install won't worked for me.
pdo_mysql.so placed in modules dir, copy it to extentions dir (php -i | grep extension_dir) and enable in php.ini.
These steps will not add PDO_MYSQL under the PEAR, so you need to maintain it by yourself. But to update list of installed packages, you can do this trick
sudo pecl install -rB pdo_mysql
-r means do not install files, only register the package as installed
-B means don't build C extensions
Some other good to read links
Topic : pdo_mysql.so driver Installation
Wednesday, November 4, 2009
Saturday, August 1, 2009
Zend Certified Engineer
I got 10 mock exams with a voucher and I wanted to do that in January 2009. So I started to prepare myself with testing tools, books and manual. You even can see my mock exams progress. But I've stopped that in a middle and this summer I decided to get this done.
So now, I'm officially Zend Certified Engineer (certificate details) born in Russia, living in Israel ;-)

Resources that can help you to reduce holes in you PHP knowledge:
- Zend PHP 5 Certification, Study Guide - must to read
- Zend PHP Certification Practice Test Book (PHP 4) - old test and answers, helped me with streams and PDO
- Guide to PHP Design Patterns
- and, of course, PHP manual with user comments (they sometimes very useful).
Saturday, March 15, 2008
ideal web environment structure tips
why to compile
i think, you should do this cause this way you can enable only required stuff for all your programs (such apache web server, mysql, php, etc).
for example, i don’t need all default modules in my apache that eat more memory than application can use. same thing — php.
configuration files
vi is good. i even know how to use it. but i prefer to make symbol links to my config files (httpd.conf, my.conf, etc) to some place where it automatically backup’d and i can access via windows editors to change, copy, share them. this files only read by daemons on startup. while windows still default os in many companies…
to be contunied…
Saturday, June 2, 2007
Image_Graph samples
Image_Graph is, as is indicated by the title, a project to create graphs. It utilizes PHP's object oriented model, to simple but very customizable enable a user/developer to create highly versatile graphs.
Friday, June 1, 2007
step 3 — compiling php 5.2.3 on debian linux
before you start anything, please point your browser to install notes from php site. you right man if you always have a fresh copy of off-line docs (best one).
first, you need to get php source code. i like swedish locations (good speed) and smaller bz2 compressions, so chose where do you want to save and extract after files and run this:
wget http://se.php.net/get/php-5.2.3.tar.bz2/from/this/mirror
now in that dir we need decompress archive. this will create "php-5.2.3" directory
tar -xvvf php-5.2.3.tar.bz2
this step is not necessary if you build it for a first time, but after you sholud do this (for finding out, why my new compile not work properly with all options that i added - i spent all day, just for this simple thing)
make clean or make distclean
cd to new folder and try to check your config
./configure --with-mysql=/usr/local/mysql --with-apxs2=/usr/local/httpd
it is never (i think) passed on first time ;-) so for this my conf i was need these packages: libmysqlclient14, libmysqlclient14-dev, libxml2, libxml2-dev, libpng3, libjpeg62, libjpeg62-dev, libgd-dev, libfreetype6-dev
also, it was a little trouble to understand, why php cant see mysql installation, this should help (we put path to mysql into linux environment PATH):
export PATH=/usr/local/mysql/bin:$PATH
if configure passed, we can smile and start make phase. (for my double P-II 350 MHz it took ~30 mins)
make -j4
-j option is for SMP systems (more than one CPU). it's CPU_COUNT*2
i found that PHP team provide us some testcases, so we can use it for find out any compiling bugs or smthing
make test
before install phase, make sure that apache is not running (ps ax | grep httpd)
/etc/init.d/apachectl stop
make install
export CFLAGS="-O3 -msse -mmmx -march=pentium3 -mcpu=pentium3 -funroll-loops -mfpmath=sse -fomit-frame-pointer"
--with-mysql
--with-mysqli
--with-apxs2=/usr/local/httpd
--with-freetype-dir=/usr
--with-tidy (libtidy, tidy, tidy-dev)
--enable-bcmath = Enable bc style precision math functions
--enable-memory-limit (prior to 5.2.1) for memory_get_usage(), memory_get_peak_usage() and 'memory_limit' configuration directive.
http://www.opennet.ru/base/net
http://www.opennet.ru/opennews /art.shtml?num=8508
Saturday, May 26, 2007
Monday, May 21, 2007
php filter
This extension serves for validating and filtering data coming usually from some insecure source such as user input.
good tutorials you can find here: Zend devzone, PHPro and php doc.
Sunday, May 20, 2007
php performance (code)
require_once "a.php";
php_version() = PHP_VERSION constant
php_uname(‘s’) = PHP_OS constant
php_sapi_name() = PHP_SAPI constant
// Slow
if (preg_match("!^foo_!i", "FoO_")) { }
// Much faster
if (!strncasecmp("foo_", "FoO_", 4)) { }
// Slow
if (preg_match("![a8f9]!", "sometext")) { }
// Faster
if (strpbrk("a8f9", "sometext")) { }
// Slow
if (preg_match("!string!i", "text")) {}
// Faster
if (stripos("text", "string") !== false) {}
$text = preg_replace( "/\n/", "\\n", $text);
In this case it would be simpler and to mention faster to use a regular str_replace()
$text = str_replace( "/\n/", "\\n", $text);
$rep = array( '-' => '*', '.' => '*' );
if ( sizeof( $globArr ) > 1 ) {
$glob = "-" . strtr( $globArr[1], $rep );
} else {
$glob = strtr( $globArr[0], $rep );
}
if ( sizeof( $globArr ) > 1 ) {
$glob = "-" . strtr( $globArr[1], '-.', '**' );
} else {
$glob = strtr( $globArr[0], '-.', '**' );
}
// The Good
if (!strncmp(PHP_OS, 'WIN', 3)) {
if (!strncasecmp(PHP_OS, 'WIN', 3)) {
// The Bad
if (substr(PHP_OS, 0, 3) == 'WIN') {
if (strtolower(substr(PHP_OS, 0, 3))) == 'win') {
// And The Ugly
if (preg_match('!^WIN!', PHP_OS)) {
if (preg_match('!^WIN!i', PHP_OS)) {
if (substr($class, -15) != 'text')
/* == */
if (substr_compare($class, 'text', -15))
References can be used to simply & accelerate access
to multi-dimensional arrays.
$a['b']['c'] = array();
// slow 2 extra hash lookups per access
for($i = 0; $i < 5; $i++)
$a['b']['c'][$i] = $i;
// much faster reference based approach
$ref =& $a['b']['c'];
for($i = 0; $i < 5; $i++)
$ref[$i] = $i;
all info from slides and other sources Ilia Alshanetsky
Saturday, May 19, 2007
php performance (environment)
this can be done in php.ini, inside your scripts or in .htaccess
<IfModule mod_php5.c>
php_value expose_php 0
</IfModule>
register_globals = Off
magic_quotes_gpc = Off
expose_php = Off
register_argc_argv = Off
always_populate_raw_post_data = Off
session.use_trans_sid = Off
session.auto_start = Off
session.gc_divisor = 1000 or 10000