PHP Error while running newly created Yii Application

If you are using PHP 5.3 and have created a new Yii! Framework 1.1 application, you will get the following error:

date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Your/Timezone' for 'Timezone Info' instead 

To get around this, just open up index.php of your application and in the first line, add the following:

date_default_timezone_set('Timezone/String');

You should replace the ‘Timezone/String’ with your timezone information. Since my timezone is Asia/Kathmandu, I used:

date_default_timezone_set('Asia/Kathmandu');

Hope this helps.

[HOWTO] Install Selenium Module for PHP in Netbeans 7.0 beta

If you are using Netbeans 7.0 beta, the plugin list may not show Selenium Module for PHP. To install it, navigate to Tools>Plugins>Settings and click on Add. Then, in the name field, enter something like “Netbeans 6.9 beta” and in the URL field, enter the following URL:

http://updates.netbeans.org/netbeans/updates/6.9/uc/final/beta/catalog.xml.gz

Now, reload the cataloge and you should be able to install Selenium Module for PHP.

Happy developing.

[HOWTO] Enable cross-domain upload with uploadify jQuery plugin

I have used uploadify v2.1.4 in one of my client’s website. According to the requirements, a form in a website had to submit data to another website. The form also contained file uploads for which uploadify was being used. But uploadify does not support uploading from another site as it uses relative url. Also, flash does not support sending/receiving data to/from another site by default for security reasons.

The solution to the second problem is easy. All that needs to be done is placing a crossdomain.xml file in the root of the server where file is to be uploaded with allowed list of sites that can send/receive data from that site using flash. Here is an example of crossdomain.xml file which allows all the sites:







To solve the second server however, the core uploadify file must be edited. For version 2.1.4, the file is jquery.uploadify.v2.1.4.js. Search for “pathName” (without quotes) and find the following block of codes:

				var pagePath = location.pathname;
				pagePath = pagePath.split('/');
				pagePath.pop();
				pagePath = pagePath.join('/') + '/';
				var data = {};
				data.uploadifyID = settings.id;
				data.pagepath = pagePath;

Replace that with:

//				var pagePath = location.pathname;
//				pagePath = pagePath.split('/');
//				pagePath.pop();
//				pagePath = pagePath.join('/') + '/';
				var data = {};
				data.uploadifyID = settings.id;
				data.pagepath = "http://yourwebsite.here/path/to/folder/above/uploadify/folder";

In the above code, replace “http://yourwebsite.here/path/to/folder/above/uploadify/folder” with full URL of your site where you have uploadify folder. For instance, if you have an application in http://www.yoursite.com/myapp and uploadify directory inside myapp, i.e. http://www.yoursite.com/myapp/uploadify, you should enter pagepath value as: “http://www.yoursite.com/myapp”. Also, make sure you include this edited javascript in the main page instead of the “min” version. Then, use the uploadify swf in uploadify directory in the new server.

Hope this helps.

[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.