[SOLVED] Widget does not exist error after using unset to remove form fields in Symfony 1.x

I am getting started with Symfony 1.4 and I learnt that form elements can be removed by using unset. However, I got error similar to the following after using unset:

Widget ‘x’ does not exist

This was because the module still consisted of files referencing to those elements. So, it is necessary to re-generate module after making the changes. For example, if you are using Propel and if the module name is job and class name is JobeetJob in frontend, the following command should be run to re-generate module:

php symfony propel:generate-module --with-show frontend job JobeetJob

Hope this helps.

[SOLVED] “[[WARNING]] The posix_isatty() is available: FAILED *** Install and enable the php_posix extension (used to colorized the CLI output) ***”

I ran the Symfony PHP Framework configuration check script in Fedora 15 and got the following error:

[[WARNING]] The posix_isatty() is available: FAILED
*** Install and enable the php_posix extension (used to colorized the CLI output) ***

To enable this extension, you should install php-process from Add/Remove Software or using yum.

su -c 'yum install php-process'

Run the check_configuration.php again and you should not see this warning again.

UPDATE: If you also see the following:

[[WARNING]] A PHP accelerator is installed: FAILED
*** Install a PHP accelerator like APC (highly recommended) ***

and want to have a PHP accelerator, you can install php-pecl-apc:

su -c 'yum install php-pecl-apc'

Google Plus is still not available for public but is only available to invited users. However, many of you already have accounts via invitation. So, you may want to have all your photos from Facebook to Google+. Here is how you can do it.

Extract and select photos for upload
Extract the archive and separate out photos if you don’t want every photo to be in your Google Plus account.

Login to Google Plus, click on the photos icon and then click on Upload New Photos button. Then click Select Photos From Your Computer button. You can select multiple files from the same folder by holding Ctrl or Shift. You can also select all files from the same folder by pressing Ctrl+A. After selecting files, don’t forget to enter album name. When done uploading, click on Create Album.

Hope this helps. Enjoy the Google+ experience.

[HOWTO] Firebug on Firefox 6

Firebug is not officially compatible with Firefox 6 since as of this writing, Firefox 6 is on early alphas. However, forcing compatibility works with it. For that, just install Nightly Tester Tools addon and in Tools>Nightly Tester Tools, check “Force Addon Compatibility” and restart Firefox. Now, you will be able to install and use Firebug.

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