[HOWTO] Setup step debugging PHP in Netbeans on Windows with XAMPP

I am using Netbeans 6.9.1 on Windows 7 with XAMPP 1.7.4 installed. I wanted to enable step debugging for PHP like I do in my PC with Fedora (see here for Netbeans PHP step debugging for Fedora). To do that, I had to follow the following steps:

Edit the php.ini file (xampp\php\php.ini) in a text editor to uncomment (remove leading semicolon 😉 the following lines:

zend_extension = "D:\xampp\php\ext\php_xdebug.dll"
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "localhost"
xdebug.remote_port = 9000

Also, search for the line containing “xdebug.remote_enable” and change it to:

xdebug.remote_enable = On

Then restart apache service.

Now, open the file Program Files\NetBeans 6.9.1\etc\netbeans.conf and find the line containing “netbeans_default_options”. Add the text “-J-Dorg.netbeans.modules.php.dbgp.level=400” at the end of the line so that it looks like the following:

netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-XX:MaxPermSize=200m -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Dorg.netbeans.modules.php.dbgp.level=400"

Now, restart Netbeans and select Debug>Debug Project. However, I have experienced it is very slow on Windows compared to the installation on Fedora.

Hope this helps.

[HOWTO] Insert widget inside content of CJuiTabs widget in Yii Framework

UPDATE: See the comment from “Mario De Weerd” below. Although it works in the same way, his technique seems more elegant.

I am using Yii PHP Framework 1.1.7 for developing a site. I needed to insert EColorPicker widget inside the content of a tab in CJuiTabs. If $this->widget returned the generated string for embedding a widget, I could use the following code to achieve this:

echo $this->widget('zii.widgets.jui.CJuiTabs', array(
        'tabs' => array(
            'Size' => array('ajax' => array('sizeselection')),
            'Background' => array('content' => $this->widget('application.extensions.colorpicker.EColorPicker',
              array(
                    'name'=>'cp',
                    'mode'=>'textfield',
                    'fade' => false,
                    'slide' => false,
                    'curtain' => true,
                   )
             );),
            //'Colors' => array('ajax' => array('colorselection')),
            'Text' => array('ajax' => array('textselection')),
        ),
        // additional javascript options for the tabs plugin
        'options' => array(
            'collapsible' => true,
        ),
    ));

However, since $this->widget() does not return the string and echoes it instead, I had to do the following to achieve this:

ob_start();
$this->widget('application.extensions.colorpicker.EColorPicker',
              array(
                    'name'=>'cp',
                    'mode'=>'textfield',
                    'fade' => false,
                    'slide' => false,
                    'curtain' => true,
                   )
             );
$colorPicker = ob_get_contents();
ob_end_clean();
    $this->widget('zii.widgets.jui.CJuiTabs', array(
        'tabs' => array(
            'Size' => array('ajax' => array('sizeselection')),
            'Background' => array('content' => $colorPicker),
            //'Colors' => array('ajax' => array('colorselection')),
            'Text' => array('ajax' => array('textselection')),
        ),
        // additional javascript options for the tabs plugin
        'options' => array(
            'collapsible' => true,
        ),
    ));

I don’t know if it is appropriate to use it like this, but in my case this worked fine.

Hope this helps.

[SOLVED] Warning: imagettftext() [function.imagettftext]: Invalid font filename in path\to\php\file.php on line NN

I am running XAMPP 1.7.4 with PHP 5.3.5 on Windows 7. When using any text related GD library functions such as imagettftext(), I get the following error:

[SOLVED] Warning: imagettftext() [function.imagettftext]: Invalid font filename in path/to/php/file.php on line NN

Normally, this happens when the font is missing in GDFONTPATH and can usually be resolved by using correct font folder, using correct font file and naming it properly in the PHP file. However, in this particular case, I’ve figured that this is the problem with GD Library or PHP because I am still getting the error even though I have done everything right. I tried WAMP but still in vain. When I tried the same in my Linux machine, everything was fine.

Here is what I did as a workaround. I removed the putenv line and referred to fonts by relative path. For example, the following sample code is the one that does not work

putenv('GDFONTPATH=' . realPath('fonts'));
$font="ariali";
imagettftext($image, $size, $angle, $xcordinate, $ycordinate, $text_color, $font, $text);

I have assumed that the fonts folder contains a file ariali.ttf and in that case, the code must have worked. However, it does not, so the workaround is to do the following:

//putenv('GDFONTPATH=' . realPath('fonts')); remove this line
$font="fonts/ariali.ttf"; //use relative path here instead
imagettftext($image, $size, $angle, $xcordinate, $ycordinate, $text_color, $font, $text);

The above code works and I guess this is how I will have to use fonts in PHP from now on.

[SOLVED] “[ERROR] Fatal error: Can’t open and lock privilege tables: Incorrect key file for table ‘user’; try to repair it”

I am working on a computer with XAMPP installed on Windows 7. When I upgraded XAMPP to fix the earlier problem with WinMySQLAdmin, a new problem with mysql was introduced. The error log (mysql_error.log) showed the following entry at the end:

[ERROR] Fatal error: Can’t open and lock privilege tables: Incorrect key file for table ‘user’; try to repair it

To fix, I downgraded to earlier version of XAMPP, exported the database and removed the mysql data directory, and reinstalled the latest version of XAMPP. Now, MySQL could start without problems. Then, I imported the data back and all was well.

[SOLVED] WinMySQLAdmin 1.4 : Access violation at address xxxxxx in module ‘LIBMYSQL.dll’. Read of address 00000000

I am working on a project on a Windows 7 machine with XAMPP installed. The version installed was 1.7.0 and it was showing dialog boxes with the following error:

Access violation at address xxxxxx in module ‘LIBMYSQL.dll’. Read of address 00000000

Here is one:
Access Violation XAMPP

I tried reinstalling, but reinstallation failed because apparently mysql\bin folder was not remove during the uninstallation. So, I stopped the winmysqladmin.exe from the task manager and removed the bin folder and reinstalled again.

Then, I was able to install XAMPP. The new version of WinMySQLAdmin does not seem to have the same problem.

[SOLVED] “417 – Expectation Failed” in PHP curl while submitting multi-part forms

I am using PHP Curl extension for a project which requires uploading file to a server I had no control over. However, I was getting HTTP Status 417 with error message Expectation Failed. I don’t know what this is supposed to do and why curl sends it, so I tried removing it by overriding it with the following code:

curl_setopt($curl,CURLOPT_HTTPHEADER,array("Expect:  "));

It worked and the file uploaded successfully.

Hope this helps.

[SOLVED] Windows Installer: The installation package cannot be installed by the Windows Installer service.

I ran into a computer with Windows XP and I got the following error while trying to install a new Windows application:

Windows Installer
This installation package cannot be installed by the Windows Installer service. You must install a Windows service pack that contains a newer version of the Windows Installer service.

I did not have time to install all automatic updates or install the whole service pack, so I downloaded a Windows hotfix from here. The file is named WindowsXP-KB942288-v3-x86.exe. I installed it and the program could be installed without problems.

[HOWTO] Install Firefox 4 in Ubuntu 10.04 Lucid Lynx and 10.10 Maverick Meerkat

Firefox 4 has been released recently and it is not available via update manager in Ubuntu 10.04 Lucid Lynx and 10.10 Maverick Meerkat. The Ubuntu Mozilla Daily Build PPA provides it but it always the latest daily build and not the stable version.

For stable version, you can use Firefox Stable PPA. To install the PPA in Lucid or Maverick, just launch Synaptic (System>Administration>Synaptic Package Manager) and then go to Settings>Repositories>Other Software. Now click Add and paste in the following:

ppa:mozillateam/firefox-stable

Close the Repositories window and then click reload. When it is done, search for firefox-4.0-gnome-support and mark it for installation. It should mark other required packages. Apply and wait for installation to finish.