[HOWTO] Configure Netbeans 6.9 to debug PHP files using xdebug in Fedora 14

I am using Netbeans 6.9 on Fedora 14 for Web development. I have enabled PHP debugging for making PHP development easier. Here is how you can do it too.

Install and enable xdebug

Use yum to install php-pecl-xdebug:

sudo yum install php-pecl-xdebug

Now, open the file /etc/php.d/xdebug.ini in a text editor as root. I use nano:

sudo nano /etc/php.d/xdebug.ini 

Now , make sure the following options are set enabled in ini:

; Enable xdebug extension module
zend_extension=/usr/lib/php/modules/xdebug.so
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000

Allow port for xdebug

sudo semanage port -a -t http_port_t -p tcp 9000 

Restart Apache:

sudo service httpd restart

Configure Netbeans to use PHP debugger

Now, open up the file /usr/share/netbeans/6.9/etc/netbeans.conf in a text editor and add the text “-J-Dorg.netbeans.modules.php.dbgp.level=400” in netbeans_default_options so that the line looks somewhat like this:

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

Restart netbeans and given that you have configured the project directories properly, you should be able to click on the debug button and start debugging PHP file.

[SOLVED] PHP Fatal error: Call to undefined method Zend_Http_Client::setRawDataStream() in /path/Zend/Gdata/App.php on line X

I am trying to use Zend Gdata Library for uploading videos to YouTube. I was trying to test the example provided, but got into a problem running the example. Here was the error:

PHP Fatal error: Call to undefined method Zend_Http_Client::setRawDataStream() in /usr/share/php/Zend/Gdata/App.php on line 661

It was because I had missed the part where I should have sent a Zend_Gdata_HttpClient() object while initializing Zend_Gdata_YouTube() object.

So, here is how I created Zend_Gdata_HttpClient() object and passed it to Zend_Gdata_YouTube() constructor. Also, video upload requires developer key which you can get from Google and username/password.

		require_once('Zend/Loader.php'); // the Zend dir must be in your include_path

		$authenticationURL= 'https://www.google.com/accounts/ClientLogin';
		Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
		$httpclient = Zend_Gdata_ClientLogin::getHttpClient(
			              $username = $user,
			              $password = $pass,
			              $service = 'youtube',
			              $client = null,
			              $source = 'An App Name', // a short string identifying your application
			              $loginToken = null,
			              $loginCaptcha = null,
			              $authenticationURL
			           );

		Zend_Loader::loadClass('Zend_Gdata_YouTube');
		$yt = new Zend_Gdata_YouTube($httpclient,"An App Name","Version something or some desc","API-KEY");

Hope this helps.

[HOWTO] Setup a Minimal Ubuntu LAMP server (with ssh server)

In this article, I will describe how I went about to install the bare minimum LAMP server using Ubuntu Minimal installation iso. I downloaded Maverick Meerkat version of Minimal CD image from the Minimal CD Image Download Page. You can use the server ISO but you may end up with unwanted packages and you will need to download the whole ~700 MB ISO to start, while Minimal CD is just ~13MB. Also, since the Minimal CD downloads the latest packages from the repos during installation, you need not update immediately further saving data volume.

I am installing inside VirtualBox 4.0 Beta. However, these instructions should apply to other Virtualization solutions or even a physical machine.

Boot into the computer with the CD Image (either burn it to business card CD-ROM or normal CD-ROM if using Physical Machine otherwise just mount inside VirtualBox) and follow the on-screen instructions and select appropriate settings that apply to you. At the last stages of the installation, you will be asked to select packages, select none. It will complete installing the basic packages and install Grub and reboot.

After reboot, you will be able to login. After logging in, enter the following command:

sudo apt-get install mysql-server phpmyadmin ssh

The above command should install the following components:
openssh-server
apache2
mysql-server
mysql-client
php
phpmyadmin

At the end of the installation, just select appropriate settings and setup passwords.

Now, when you launch a browser in another machine, you can open http://IP.OF.THE.MACHINE and you will see that system is ready, if everything went right. The installed size is less than 1GB (excluding swap).

Hope this helps.

[HOWTO] Install Eclipse-PDT (PHP Development Toolkit) in Debian Squeeze using Yogarine PPA Repository

While you can download the latest version of Eclipse PDT from Eclipse Download Page and install it manually, it is great to setup a repository instead so that you can get updates from it automatically via update manager. Eclipse is available in the official Debian repos but PDT is not. It is available in Yogarine Eclipse PPA in Launchpad. For Debian Squeeze, add the following line to Sources.list (or add it via Software Sources or in Third Party Repositories in Synaptic):

deb http://ppa.launchpad.net/yogarine/eclipse/ubuntu lucid main

Then execute the following command as root to add GPG keys:

apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 676DBA91

Now, reload your software list:

apt-get update

Then, install eclipse-pdt:

apt-get install eclipse-pdt

You may not get the latest version, but the repo is constantly updated and easy to manage than to monitor and re-download the same from Eclipse download page and update.

[SOLVED] Fatal error: Call to undefined function xmlrpc_encode_request() in /path/to/a/php/file on line x

I was trying to use xmlrpc_encode_request() for posting to wordpress for one of my sites and got the error similar to the following:

Fatal error: Call to undefined function xmlrpc_encode_request() in /path/to/a/php/file on line x

This happened because the server did not have xmlrpc extension for PHP enabled. If you are getting this error on a shared hosting server, you are almost out of luck. However, you can still talk to support to have it installed. If you have your own VPS or Dedicated, you can install and configure it on your own. If you do not have it installed, you can install it by typing in the following (as root of course):
Ubuntu:

apt-get install php5-xmlrpc

CentOS/Red Hat:

yum install php-xmlrpc

If it is already installed, but disabled, you can go to the following directory and enable it:
Ubuntu:
/etc/php5/conf.d/
CentOS/Red Hat:
/etc/php.d/

Look for xmlrpc.ini. If it does not exist, create it. Now, make sure it has the following contents:

; Enable xmlrpc extension module
extension=xmlrpc.so

Make sure there is no semicolon in the beginning of second line. Save it.

Now, if PHP is loaded as apache module (most probably it is the case), you will need to restart apache for changes to take effect. Run the following to restart apache:
Ubuntu:

service apache2 restart

or

/etc/init.d/apache2 restart

CentOS/Red Hat:

service httpd restart

or

/etc/init.d/httpd restart

Hope this helps.