jQuery LED Banner – fun with jQuery!

While coming home, I’ve seen a super store showing their items on a big LED type banner. Where item names were scrolling using some lights on/off. It’s an everyday scenery, nothing special.

But I’ve come to realize soon, in back of my head, I am thinking how it can be made for web. And, LED banner has landed on earth within few hours using the wings of jQuery. Here is the fun!

jQuery LED Banner

Continue reading →

Taking Zend Framework workshop on Dec, 09

Bbjobs has arranged a workshop on “Zend framework fundamental” on December, 09  and invited us (me and Emran Hasan) to take it. We agreed happily. This is (so far I know) the first formal Zend Framework workshop in Bangladesh. The workshop has been defined as –

The Zend Framework Workshop is a 5 half-day tutorial-style course that takes an in-depth look at Zend Framework and its components. The workshop is designed for experienced PHP programmers who want to learn to combine ZF concepts and structural elements to utilize the full power of this software development kit for PHP 5 applications.

As per our plan about the context of this workshop, we are going to cover the following 8 basic topics of Zend Framework in 5 days.

Continue reading →

Book review: PHP Team Development

PHP Team DevelopmentThree weeks ago, I was contacted by Packt publishing asking if I’d review their new book “PHP Team Development” by Samisa Abeysinghe. I agreed and received the book. But, after reading it, I was wondering about how to tell negative things politely.

In the mean time Lorna Jane, Brandon Savage, Ken Guest, Walter Ebert and some other people wrote their review about this book. And I found, most of their opinion supports my thoughts on it. Actually, most of the things that I thought has already been said in their posts. So, I am not going to repeat them and will tell my views shortly.

This book will introduce teamwork and some development processes (XP, Scrum) to fresh devs . It has brief introduction about source control, bug tracking, continuous integration and many other important terms of software development. These may help a beginner who have made software for university assignments but never worked in a professional team. The author had intention to describe the complexity and some commonly occurring problems of software development with suggesting solutions.

It presents MVC as the way of working of a team and tried to solve everything(!) with it. As some others mentioned, the author has presented his solutions as the only way of doing something. It didn’t enlighten the readers about other available solutions. Also, a few of the topics did not seem to be related with the context of this book title.

This book mentioned about many tools, processes and methods – but most of them are not explained up to such a level that one can implement them after reading the book. Some concepts of the book seemed unrealistic to me. For example, separating teams based on concern (one team will work with model, another with view; and tie them up together later).

Like Walter Ebert said, this book seems to be a “quick ‘n dirty guide on team development” to me. About recommendation, I’d say, if you are a beginner in PHP (also in programming) and just know how to connect and retrieve data from MySQL, then the book can help you know many of the terms which you should study next. If not, then you should spend some time on finding a better book to start with.

Simple PHP PDO Wrapper : light, static, easy

A few days ago, I was looking for a PDO wrapper to work with a small PHP application. I’ve searched around and found fractalizer’s PDO wrapper nearest to my purpose. Then I just wrote my wrapper on the shadow of his one.

Let’s see what’s inside and how it works.

Features

  1. Easy to use.
  2. Works with MySQL and Sqlite.
  3. All pubic functions works statically.
  4. Connection string created internally.

Get the files

From github, you can clone/fork/ download the files.
Github repository https://github.com/ajaxray/static-pdo

The download archive/repository includes –

  • Db.php – the PDO Wrapper class.
  • DbTest.php – Unit testing class for Db.
  • DbExample.php – Example of some common uses.
  • Some other unit test related files.

Continue reading →

jQuery – Presentation at phpXperts Seminar, 09

At the phpXperts seminar 2009, I gave a talk on  “Blessings of modern javascript framework – jQuery” and it seemed well-received. I enjoyed giving the presentation very much!
Special thanks for all the organizers, group members and participants.

Here is the slide available for you.

Hope you’ll Enjoy the slides! Suggestions are welcome.

Extjs quick start guide for jQuery Developers

I’ve seen many people (including myself) trying out the power of jQuery for once and then getting stuck with it. Why not? It’s one of the coolest and smartest JavaScript library out there. However, I have broken out from the circle and found that Extjs is another great mentor in the field of JavaScript libraries. Especially, I think it’s UI components are unbeatable (Dojo can be a nearest candidate).

If you are habituated to think JavaScript coding in the syntax of jQuery, you can start working with ExtJS right now (with a few twist)!  What you need is some little tuning in concept and syntax. Today I will be trying to explain how to do this in 6 important points :

  1. Document is ready – How to get the our document ready and where to start.
  2. Selecting elements – How to select elements in Ext.
  3. Dom scripting – Changing on and in the element.
  4. Ext events – Assigning and firing events.
  5. Ext Components – The powerful alternate of jQuery UI.
  6. Ajax – Making Ajax request in Ext.

Ok, let’s dive in to deep of each of these points.

Continue reading →

Advanced bootstrapping : Configure your Zend Framework application for multiple host

This tutorial is intended to explain a way of bootstrapping Zend Framework based MVC application for multiple host/domains. Before starting, let me explain a bit about the situation when it’s needed.

A web application goes through some stages when growing up. Generally, it starts from development and ends at production. There can be some more stages within this two ends. And, in maximum cases this stages are overlapped. The overlapped stages can be hosted in different servers with different settings but shares the same code. In this situations, if we want to keep bootstrap in SVN repo, it needs to setup bootstrap in a little different way. So that, it can handle many server settings with a single bootstrap.

For example, just now I am working on an application which is being developed in 3 local machines (me and two other members of my team) and being tested in our staging server. Besides, our client is monitoring progress of current sprint in their staging server and testing completed sprints in their pre-production server. Here, except the production servers, all hosts contains a checked out copy of code from a single repository. But this hosts have some difference in their library path, database host and authentication etc.

If my assumptions are ok for you, let’s start after downloading.

Assumptions


I have assumed that you are familiar with Zend Framework. And already worked on (atleast one) ZF MVC application. You know the basic things about bootstrapping and using the most common directory structure (shown in image). However, you can tune this technique for your favorite Zend directory stracture.

Download files

Downoad the files from here. The zip file contains –

  1. index.php – This is the bootstrap file. Your .htaccess file points all request to this file.
  2. config.xml – Contains all configurations of your application, for all hosts.
  3. Bootstrap.php – A php class that handles all startup settings in a vary organized way. (I don’t know who first wrote it, Thanks to him)

Continue reading →

Front-end optimization with PHP Speedy – increase Yslow grade in 10 minutes!

Before I move into PHP Speedy, a small background won’t hurt much! Until a few days back, whenever I hear the word optimization, my brain quickly shows a few keywords in my mental screen: “query optimization, page caching, opcode, etc”. All these terms and the associated work relates to the optimization of a web application in the back-end. This has been serving my need pretty good, until I became aware about the excellent 13-point front-end optimization techniques from Yahoo (thanks Emran bhai).

At first I was a bit skeptical, but as soon as I started seeing the points – I knew its importance. Without much delay, I gave it a short in my latest project at work. And the tool that made it a less than 10 minute work is: PHP Speedy. I am literally speechless with it’s performance and way of working. Just in 10 minuets, It upgraded the Yslow grade of our project from 43 to 88.  Just like a magic touch!

php_speedy_logo_medium

Now, let’s see what Yslow Grade is (for those who are not yet using it) and how php-speedy helps to upgrade it. Hope this enlightens someone like me 😛

Continue reading →

PunBB modification – Implementing iconized categories for forum topics

PunBB is one of the fastest and minimal forum softwares powered by PHP. PunBB says about itself:

PunBB is a fast and lightweight PHP-powered discussion board. It is released under the GNU General Public License. Its primary goals are to be faster, smaller and less graphically intensive as compared to other discussion boards. PunBB has fewer features than many other discussion boards, but is generally faster and outputs smaller, semantically correct XHTML-compliant pages.

You can see a detailed review about PunBB from forum-software.org.

What’s the purpose this mod?

PunBB has categories for forum. But there is no categorization for Topics like many other forums. This mod implements an iconized category for topics. The end result of this mod is –

  • It will add an excellent looking “Category Icons” fieldset in “Post new topic” form. (see Image#1)
  • Users can (optionally) select a topic category while posting a topic.
  • The category icon will be displayed beside the topic title in forum index page, topic detail page, search result etc. (see Image#2 and Image#3)
  • Clicking on a category icon will show all topics under that category.(see Image#4)

Lets see some screenshot of this modification :

Category icons in "Post new topic" form

Image#1:  Category icons in Post new topic form

Category icons before topic title in forum page

Image#2: Category icons before topic title in forum page

FireShot Pro capture #5 - 'User Contributed Deals _ Television is poluting our culture' - local_deals_com_forum_viewtopic_php_id=5

Image#3: Category icon in topic page

FireShot Pro capture #7 - 'User Contributed Deals _ Search results' - local_deals_com_forum_search_php_search_id=1345131291

Image#4: Filtering by category

Continue reading →

Image manipulation in Zend Framework using PHP Thumbnailer Class v2.0

In the huge set of library, Zend Framework have no options for manipulating image. There is a proposal for Zend_Image which aimed to provides easier image manipulation using GD. But the proposal was not considered. Bill Karwin of ZF said,

Proposal not being considered

This proposal has been reviewed. The proposal describes functionality that is very similar to the existing PHP interfaces for ImageMagick or GD.

We are not considering this for inclusion in the Zend Framework at this time.

So, what to do when we need to make image thumbnail, resizeing or cropping image etc in Zend Framework?

The Solution

Zend Framework has the extensive power of integrating any library. So, we can use ImageMagick or GD library or any wrapper class using this libraries for manipulating image.

Here, I am explaining creating image thumbnail using PHP Thumbnailer Class v2.0 in 2 easy steps. I am assuming that, you are using Zend’s MVC with common directory structure and you’ve GD library with your PHP installation.

Step 1 – Create a Model for image manipulation :

Download the PHP5 version of PHP Thumbnailer Class v2.0 and put the class file “thumbnail.inc.php” in your model directory. Now change the file name to “Thumbnail.php” as it’s class name. Now your model is ready for action.

Step 2 – Use this model in Controller :

In your Controller, write a function to make thumbnails using this model. For example, you can use this function below:

   1: /**
   2:  * Create thumbnail of an image
   3:  * 
   4:  * @author    Anis uddin Ahmad (http://ajaxray.com)
   5:  * @param     string    Path of source image
   6:  * @param     string    Destination path of thumbnail
   7:  * @param     number    Width of thumbnail
   8:  * @param     number    Height of thumbnail
   9:  * @param     number    (optional) thumbnail image quality 
  10:  */
  11:
private function _createThumbnail($sourcePath, $destPath, $w, $h, $q = 100)
  12:  {
  13:     $thumb = new Thumbnail($sourcePath);
  14:     $thumb->resize($w, $h);
  15:     $thumb->save($destPath, $q);
  16:  }

Done. Now you can use this function to resize/make thumbnail of an image. To resize an image with keeping it’s original name, pass the $sourcePath again in $destPath parameter. Then it will overwrite the existing image.

So, was it so though to manipulate image in ZF?