Category Archives: PHP

Sample PHP Application: A Simple PHP Command Line-based File Generator

PHP is a great scripting language to build web applications. Reckoning my first exposure to the language, I have been tinkering with PHP for some years by now. Despite the sluggish improvement and development towards a more architecturally robust, more feature-rich, and less quick-and-dirty programming language recently, I still love coding bytes in PHP. Some people may think of PHP as the language for programming the web quickly. Write some HTML, embed some javascript, add some CSS, put some PHP code, and voila… a dynamic web page is created. I won’t praise how good PHP is for developing a web application. Several companies may have done that. Name Facebook and Yahoo as examples. With some optimization to native PHP codes, both companies have shown how to use the language to cater to millions of users and run a serious business.

In this post, I’d like to highlight another feature of PHP, the command line interface (CLI). In my personal experience, PHP CLI can be an alternative to some administrative tasks. Linux users may have been familiar with shell scripting for carrying out system management and configuration tasks. So, why must PHP? The answer is portability. The same PHP code should work not only on Linux but also on Windows. Some critics may argue that other languages may also have answer for portability. I concur to that criticism while at the same time emphasizing PHP as another viable option.
Continue reading

Quick Tip: How to Install and Configure PHP in Fedora Linux

Previously, I have discussed about how to install MySQL on Fedora Linux. In this post, I would like to elaborate PHP installation on Fedora. Even though the installation is simple by nature, I would like to provide some notes to help you troubleshoot some post-installation problems that may occur.

As usual, I will provide the screenshots of the installation along with the commands invoked on the terminal. For the environment, some important settings are written below:
OS : Fedora 13 64-bit
Web server : Apache HTTP Server
PHP version : PHP 5.3.2
Constraints : yum is installed, commands invoked in root shell, Apache is already installed and running

Note: Apache is installed by default in Fedora. You only need to configure and verify that the server is running. How to configure Apache is explained in the online documentation. If you want the server to be public, i.e. accessible from other computers in the network, you should not firewall the HTTP port, which is usually port 80. Also, if you enable selinux, you also need to properly set the flag of some security parameters related to http. I will explain about selinux and http in another post.

Now, let’s move to the installation. Basic installation steps are as follows:
1. Install PHP via yum

root# yum install php


Continue reading

Sizzling Upload Progress Bar in PHP with APC, Part 1: APC Installation

After some series of “political” technical notes, I think it’s the right moment to supply some more technical posts to fellow developers. This time I will write about creating sizzling upload progress bar in PHP. In the past, there had been heated debate in PHP internal list about RFC 1867 implementation on PHP core code. If you were there, you might still remember that we had to patch the file main/rfc1867.c and some other files and then recompile PHP to get the upload progress bar hack working. Some harsh critics even mentioned that without the built-in capability of upload progress, PHP was years behind Java and Perl and lacked its capability as a web programming language.

Fortunately, since PHP 5.2 (especially after PHP 5.2.6 release), showing upload progress is not a big deal in PHP. Thanks to APC developers -mostly are also core PHP developers- who contributed to changes in APC that led to the availability of this long-waited feature. With APC we’ll be able to track the progress of file upload and provide our users better convenience when using our application.

Still, APC is not a part of core PHP shipped as a bundled package. We need to install it manually. In Windows, we can simply load the dll file to get it working. However, Linux users may need some pointers about how to install and enable this package. Hence, I will provide some guide for APC installation which was tested on veteran RHEL 4 and energetic young Fedora 10. So, let’s just go to the installation part. Continue reading