Here is a simple steps to install JSON for PHP in *nix server. The sample command below are running under Centos OS.

yum update "*php*"

Make sure you have install PHP Pear.
yum install php-pear

and The pecl command can then be found at /usr/bin/pecl

Then, we can start install PHP JSON.
pecl install json
cd /etc/php.d/
echo “extension=json.so” >> json.ini
service httpd restart

If you are using JQuery with JSON, take a look at this JQuery Json Library. Easy to use and simple.

ImageMagick PDF to Image conversion or Vice versa

Using Linux version of ImageMagick to convert PDF to Image

convert -density 140 test.pdf -resize 25% -quality 100 -colors 256 test.png

You can even use PHP ImageMagick library to convert pdf to image file.

For more information can be view from here :

Allow Apache PHP to access Unix Command or software.

Recently i was working with ImageMagick software (Open Source), basically a very powerful image suite to create, edit, and compose bitmap images. It can manipulate any sort of image just by using command line. Image using Photoshop with command line.

But calling an ImageMagick command using PHP Web pages required some configuration in the visudo files. Apparently, by default unix os will restrict any call or process that do not have any permission to access the internal command. If you wish to execute ImageMagick, you either required to use root user or user who is allowed externally to access the command. One of the way is to enable apache user, remove the Required TTY with visudo and add this to line into visudo (APACHE ALL = (ALL) NOPASSWD). I won’t say this is the only way, but this is one of the most easier. You can either use the PHP ImageMagick library or create and assign a group for apache that are only allowed it to access certain thing in the unix.

But the problem with using ImageMagick PHP library packages is that you can’t have much flexibility and control compare of using the command line.

THIS STEPS BELOW ARE NOT RECOMMENDED IF YOU DO NOT WANT TO RISK YOUR WEB SERVER.THIS SOLUTION ARE ONLY FOR TEMPORARILY RELIEVED UNTIL YOU FOUND A SAFER SOLUTION.

1. Open up your sudo configuration using visudo command.
2. Find the line Required TTY and comment it out using #Required TTY
3. Add another line that remove required password when apache trying to use the command. : APACHE ALL = (ALL) NOPASSWD
4. Restart your apache and you are done with service httpd restart. Check your apache error log if you still can’t run the command to access ImageMagick.

Here are the list of ImageMagick PHP Packages :
———————————————-
MagickWand for PHP (PHP)
IMagick (PHP)

Google VS PHP

Here is the recent article Google published for Web optimisation technique for PHP. It got bad PHP community slap back especially from the Sitepoint.com and Google group forum. It is quiet interesting to see how beginner PHP will actually fall in the trap which recomemded so of the tips from the articles.

My Favourite Web Development tools.

Every few months, i will be Googling or check out new web development tools for my work and personal projects. Unbelievably,  new cool and fantastic tools kept popping up, something you even have problem which best tool to used. The tools i meant here, are tools like IDEs, plug-in, library, framework, CMS, test-suite and more. Below, are the list of tools that currently i am using and found it very useful and increasing my productivity. All the tools are OPEN  SOURCE which i am a very big fan of.

Firefox Add-ons

——————-

1.  Again, Firebug win my heart. This tool let you inspect and edit CSS on the fly. Not only css, debugging javascript with it, save tons of your time to look for javascript errors.

Firebug screen shot

Firebug screen shot

2. iOpus iMacros – from a Firefox add-ons : to record form filling and replay the task you had been recorded. Save your time kept repeating testing for web forms, useful for web testing, web scraping and more.

IMacro

IMacro

3. Web development– from a Firefox add-ons : Great tools with lots of functionality for web developers. Such as markup validation,  cookies management, http header management and more.

Web Development toolbar (Firefox add-ons)

Web Development toolbar (Firefox add-ons

4. XDebug for Javascript

5. Yahoo YSLOW – Javascript profiler : A great tools to check how to faster up your website. Their also provide best practice and guideline how to improve and tune website loading performances.

Framework

————–

1. Zend framework : started using recently and fall in love with it. Strong MVC architecture support and database adapter.

2. jQuery : A Cool Javascript framework that i have been using almost 2 years since it released. JQuery have strong community support, easy to learn, good documentation (at least better than some), more books on JQuery and more.

CSS

—-

1. 960 Grid System from MIT. Very easy to use and faster up your layout  design for a new website without worrying if the new row or column will expand accordingly.

Forum

——–

1. Although this part is a bit not relevant, but i insist to introduce the best question and answer programming/IT forum : http://www.stackoverflow.com

2. Slashdot : Ah!!..sometimes you need a break from your IDE or notepad.

Time Tracker

—————-

1. I use RTM : Remember the Milk task list which integrate well with Gmail Task List.

2. Google Calendar : Use it for weekly planner and task remimder which sent free sms reminder to your mobile phone.

PHP Coding Pratice.

If You are PHP Developer and wanted to improve your coding standard here is the start.
Although those tips looks simple and for Cake but guess what it had the power to impact your coding standard. I have been trying to code in any language with the standard provided and yes!, at first it is hard. Then when you used to it, it became a habit. Cheers.

Tips for Installing WS02 WSF/PHP Extension

If you happen to use Web service running on WSO2 WSF/PHP as server or client and this is your first time configuration here are some tips might helping you if you get this error Messages (WSClient not found: ….) or when you tried to run phpinfo() and didn’t found wsf almost bottom of the html page when trying the samples code from WSO2 WSF/PHP Ext. It might be you have not set the path or copy the 3 required file.
1.Libxml2++.
2.iconv-++
3.zlib++

Download these files.
Make sure you follow exactly the tutorial provided from WSO2 WSF PHP/Ext Website

Tips
1. Try to run “php -m” without the quote from Window Command Prompt.
2. If it happen a pop-up dialog box mention you required one of those 3 files then you had to set the path an Environment. For example : C:\libxml2-2.6.30+.win32\libxml2-2.6.30+.win32\bin and etc.
2. Copy the libxml++.dll file into your C:\path\wso2-wsf-php-bin-1.2.1-win32\wsf_c\lib and same as the rest.
3. Close the previous command prompt. and rerun the command prompt again. Try to run “php -m” and it might fix the problem.
4. Check the list that shown make sure all those 3 files are listed.
5. Now the wsf will be shown out.
6. Restart your apache server or restart your PC if required. The wfs will be shwon in phpinfo(). It happen to me that it required me to restart the server several time until the wsf shown. Weird.
7. Anyway, try the sample client. It might be working now.

Happy Coding.