Free PHP Classes & Library

Convert Object to Array in PHP

There are quite a few ways to do this and each of them has its strengths and weaknesses. Find out if one suits your needs by trying one of the approaches below. Casting with (array) $array = (array) $obj; Problem is this doesn’t convert complex / multi-dimensional objects well. get_object_vars() $array = get_object_vars( $obj ); …

Convert Object to Array in PHP Read More »

PHP Class for Handling .htpasswd and .htgroup (Member Login & User Management)

Apache is a marvelous web server that offers .htpasswd and .htgroup for controlling restricted access to your website. By help of .htaccess, they work as a member login & user management system that is so simple and easy to deploy. You can even define user groups / roles with it. Basically, .htpasswd defines pairs of …

PHP Class for Handling .htpasswd and .htgroup (Member Login & User Management) Read More »

PHP: Crontab Class to Add, Edit and Remove Cron Jobs

Provided that your user account on the server has the privileges to access crontab thus can create or remove cron jobs, you can use this PHP class to integrate crontab in your application. I created it for many of my own projects that need crontab to do scheduled jobs. It’s pretty straightforward. Don’t know what …

PHP: Crontab Class to Add, Edit and Remove Cron Jobs Read More »

PHP Class: Convert Plural to Singular or Vice Versa in English

I was trying to find a PHP function or class that can convert English words / nouns in plural form into their singular form so that wordcrow.com automatically detects and redirects plural lookup to the singular page. After a while searching on Google, I found this class. This great class (Inflector) was ported from Ruby …

PHP Class: Convert Plural to Singular or Vice Versa in English Read More »

PHP: File Upload Script (HTML Form + PHP Handler Class)

It’s sometimes cumbersome to handle uploaded files — checking if it is really uploaded, moving and renaming. Why not writing all these chores into a class and make our own file upload script? First we are going to create a simple class to handle uploaded files and move them to some place we designate for …

PHP: File Upload Script (HTML Form + PHP Handler Class) Read More »

PHP: Resize Image and Store to File

While there are a lot of methods for you to resize images with php, we will be using extension gd this time. Make sure you or your hosting company has installed it in the php distribution by running <?php if (extension_loaded(‘gd’)) { // return true if the extension’s loaded. echo ‘Installed.’; } else { if …

PHP: Resize Image and Store to File Read More »

What is PHP framework & Who are the Best PHP Frameworks?

Basically, PHP frameworks are programming layers that are promoted above PHP itself and that are much easier and quicker to deploy, normalizing and packaging 80% of the routines one is expected to work on without them, such as database interfaces. Therefore they free you from the chores of coding from very scratch line by line …

What is PHP framework & Who are the Best PHP Frameworks? Read More »