Friday, November 30, 2007

Easy setup and configure WampServer - MySQL5, PHP5 + PECL, Apache2, PhpMyAdmin on Windows XP

WampServer is a Windows web development environment. It allows you to create web applications with Apache, PHP and the MySQL database. It also comes with PHPMyAdmin and SQLiteManager to easily manage your databases.

WampServer installs automatically (installer), and its usage is very intuitive. You will be able to tune your server without even touching the setting files.

WampServer is the only packaged solution that will allow you to reproduce your production server. Once WampServer is installed, you have the possibility to add as many Apache, MySQL and PHP releases as you want.

WampServer also has a trayicon to manage your server and its settings.

Thinwire - Next generation Ajax Framework

ThinWire is a development framework that allows you to easily build applications for the web that look and feel like the desktop applications you're familiar with. ThinWire focuses exclusively on a server-side programming approach, rather than the blended client-side & server-side approach taken by many frameworks. A benefit of this approach is that your code base is typically written entirely in a single language on the server and therefore traditional development, debugging and unit testing methods work without modification. Further, this allows developers to spend their efforts focusing on implementing the actual business needs rather than tackling many of the complexities associated with client-side development. While virtually any web application can be built with ThinWire, when it comes to business applications, we feel there is no faster solution on which to build. To that end, a number of business banking applications built on ThinWire are currently used at a production capacity, one of which is at a top ten bank in the United States with over 1000 users.

  • Build Web apps with ThinWire and Java code, Part 1: Manage Web app layout
    ThinWire, an open source development framework, you can build Web applications that look and feel like desktop applications. In this five-part series of tutorials, you'll learn how to develop rich Web applications using ThinWire and Java(TM) programming. In Part 1, you begin the process and learn how to deal with user interface layout issues in ThinWire. You will discover in this tutorial that providing dynamic layout management using the ThinWire framework is a relatively easy thing to do.
  • Build Web apps with ThinWire and Java code, Part 2: Using the SplitLayout Class
    With ThinWire, an open-source development framework, you can build Web applications that look and feel like desktop applications. In this five-part series, you'll learn how to develop rich Web applications using ThinWire and Java. In Part 2, you learn to use the SplitLayout class in conjunction with your own layout management code to dynamically change the layout of a ThinWire GUI based on the current size of the Web browser window.
  • Build Web apps with ThinWire and Java code, Part 3: Styling support
    ThinWire, an open-source development framework, you can build Web applications that look and feel like desktop applications. In this five-part series, you'll learn how to develop rich Web applications using ThinWire and Java programming. Here in Part 3, you learn to use ThinWire styling support at both a global level and an individual component level.
  • Build Web apps with ThinWire and Java code, Part 4: Write a template class
    ThinWire is an open source development framework that lets you build Web applications that look and feel like desktop applications. This five-part series explores how to develop rich Web applications using ThinWire and Java programming. In this installation, learn how to write a template class that defines one of the most commonly used Web page layouts.
  • Build Web apps with ThinWire and Java code, Part 5: Page switching
    Part 5 of the "Build Web apps with ThinWire and Java code" series explores a methodology for separating your ThinWire and Java Web site into multiple pages, providing the ability for your clients to switch among those pages using either direct pointer links or sequential page access.
  • Developing Ajax Web Applications using ThinWire and Java
    For those who know how to write stand-alone, event-driven Java/OOP applications, this is the easiest way that I know of to develop rich web applications.

MySQL Singleton Class with PHP5

The singleton can be use in lot of differents cases. In this exemple we will make a MySQL connection Singleton class. This will help us to always use the same connection.

class MysqlDB{
static private $instance_MysqlDB = null;


* Instantiate the object

private function __construct(){
$this->objMysqli = new mysqli("localhost", "root", "", "mysql");
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
* Perform a query
* @param string $sql

public function select($sql){
* Var dump the current object

public function var_dumping(){

* Get the current instance for the object
* @return object
static public function getInstance(){
if(self::$instance_MysqlDB == null){
self::$instance_MysqlDB = new self;
return self::$instance_MysqlDB;

To use the singleton we will never use the constructor method. We will call the getInstance method.
Here is an example :
MysqlDB::getInstance()->select("SELECT * FROM `help_category` LIMIT 5");

Zend Framework Overview creator Nick has explained why he chooses Zend framework among the other PHP5 frameworks.

Is it a framework?

The first thing that I always have to explain when talking about the Zend Framework is that to me it is not a ‘framework’ or not in the same way others are frameworks. This causes a lot of confusion and misunderstand of what the Zend Framework has to offer. To me most frameworks require you to conform to how they ‘think’ (something Ruby/Rails suffers from) and breaking out from their thinking requires actual alteration of the framework.

To me the Zend Framework is actually a Library, something that I can pick and choose from and although a good percentage of each module does also interact with other modules this behavior can in most cases be overridden or sub-classed and behaviour changed.


Another difference is that a lot of Frameworks revolve around their own implementation of the MVC (Model View Controller) and again if you want to break out from how they work then you may as well not use any of the framework. The Zend Framework does of course include modules that assist in setting up a MVC and it has many great tutorials on ‘the standard’ way of doings things. But once you begin to understand how everything fits together it has incredible power for those who want to stretch its legs.

Not for beginners?

I will at this point make lots of enemies by saying that the Framework is a professional product and is not really for the beginner. Although it has made strides towards simplifying some aspects of the MVC (and other modules) it is still certainly more complex than others and if you have no inclination to do anything ‘out of the ordinary’ then my advice is to use something else.

The Modules

The Zend Framework as I mentioned earlier is made up of a range of modules (full list here) most of which uses at one level or another. I wont go into detail for all of them as I would just be repeating what is said in the manual.

Zend_Acl - Access Control List

I have previous written at length about the ACL and done a podcast on the subject. It is a little hard to get your head around to start off with (the reason I tried to explain it in the PodCast) but it is extremely powerful and versatile.

Zend_Auth - Authentication

Authentication made simple. Although again we have sub-classed and extended the functionality it again got us up and running within hours and then let us think about the more complex tasks by filling in the basics.

Zend_Cache - Caching

The cache is fundamental for anyone who is serious about long term scalability. It allows caching of pages/parts of pages or just raw data. It has two killer features for me 1) Range of backend solutions (File,SQL, Memcache, ZendPlatform) 2) Tagging. The back end options give me great flexibility to choose the right kind of caching for the situation plus it is easy to extend to add your own. The tagging is a delightful way to group together different pieces of information so that they can be cleaned up / listed by tag or tags.

We created a whole new interface so we could view the current state of the various caches we have and allows us to clear out entries by key (every item must have a unique key) or by tag.

For anyone thinking about investing in Zend Platform it also means that when that time comes that any caching can be handed over to the platform.

Zend_Controller / Zend_View

I am a massive fan of well structured MVC’s and the Zend Framework gives me the flexibility to do everything we could possibly want. As default creating mapping between URL & method/controller gives you quick setup. You can then easily extend the routing (how a URL gets translated).

We have a whole set of custom routes, we have a fully sub-classed dispatcher and make use of the helpers when we can.

The Zend_View is quite simple as a starting point but is easily extended and can achieve a range of design patterns. We have various extensions to give us partials and layouts. The partials allow us easy blocks that have local variables assigned to render pages. The layout lets us arrange numbers of blocks/sections.

Zend_Db - Database

I cannot recommend Zend_Db enough! It is at once very simple to get going but fantastically full of depth. I had never considered myself much of a database expert and Zend_Db allowed me to think about the programming problem rather than SQL. The ability to build select statements programmatically with a consistent interface is a dream come true.

Zend_Feed is all about feed aggregation and Zend_Feed gave us a fantastic head start on consuming and producing feeds. We have sub-classed this heavily as we have a lot of special requirements but it did save us lots of time covering the basics.

Zend_Filter + Zend_Filter_Input + Zend_Validate

I put these all in together as they all have similar tasks. Although at first I found constantly building up filter/validation chains long winded (but very readable) I soon starting building helper functions that let me build the chains with shorter (not sure if clearer) syntax which could then be easily repeated.


const FILTER_EXAMPLE = 'Alnum:Alpha:StringTrim';
$string = Filter_Helper::filter(FILTER_EXAMPLE,$string);

The same can be applied for building up Validators. At some point I will release the full syntax and the code.

The Rest

  • Zend_Gdata - Easy to use and very powerful, we use it to access blogger services
  • Zend_XmlRpc - This is still in its infancy but it still does the job for most tasks
  • Zend_Http - Want to perform some custom request? this handles nearly everything, we use it all over the place for a range of tasks and has proved to be very robust
  • Zend_Date - Dates come in lots of formats and Zend_Date means you treat them all the same, a few question marks over future performance when over using this
  • Zend_Log - Does what it says on the tin, quite lightweight but easily extended to give a few extra features that makes it worthwhile
  • Zend_Session - I try and keep clear of over using session data but having the ability to namespace your sessions makes this very useful


The Zend Framework does a fantastic job of giving you a professional quality set of tools to get going with quickly and then when required it doesn’t stop you customizing it when you need to. As you grow more confident and start to understand the underlying reasoning behind the framework you start to work with it more and more and it encourages you to achieve the same kind of extensibility that it has achieved.

Thursday, November 29, 2007

Beginning Symfony tutorial - Moving from plain PHP to Framework based development

Lately, i have been busy with recent two projects, which are being developed using Symfony framework. Let me say that it is fantastic. I wonder why i didn't use it before. Symfony is PHP5 framework inspired by Rails framework, exactly suitable for Web 2.0 application development. I planned to write tutorial about how to start Symfony, but realized that there are plenty of good tutorials out there. One of them is on sitepoint. Here is the tutorial, you can follow the links to read the rest of the Symfony tutorial

With the release of symfony 1.0, it's time for those who haven't tried it yet to see what's inside this beautiful framework. Stable, fully documented, and released under the open-source MIT license, symfony is used by hundreds of web sites, including some very large ones (Yahoo! Bookmarks, with its 20 million-strong user base, is built with symfony). If you haven't taken the time to look at the introductory screencasts on the symfony project website, this simple tutorial will lead you through the basics.

The best way to learn and understand symfony is to use it, so this article will lead you through the creation of a photo album application with this framework. You already know the basic features such an application should offer: the ability to upload photos, to describe and tag them, and the ability for visitors to browse and comment on your photos.

Symfony is a Model-View-Controller (MVC) framework written in PHP that's aimed at building web applications. If you're already familiar with the MVC paradigm, you won't be surprised by the way symfony organizes scripts. If you aren't familiar with MVC, you just need to understand that separating the code into three parts -- the logic code (called the Model), the presentation code (the View), and the request handling code (the Controller) -- is a good way to ensure the maintainability and reusability of code.

Not only is Symfony an MVC implementation in PHP, it also integrates a lot of objects that facilitate the development of web applications -- and integrates them all with a coherent syntax. Smart URLs, code generation, easy templating, internationalization, caching, automated form validation, and Ajax, are among the most appreciated symfony features. Developing an application with symfony is slightly different than building it with any other framework, or without any framework at all. It's faster, more productive, and just plain fun. But enough talk, let's see some code.

Read more at Sitepoint>>>

Now php scripts are developed that are more compatible to generate highest pay per click revenues. These are a nice choice for the webmaster that is a beginner, since php based web design is not easier to develop and master. A beginner can just think of getting cheap domain names and high speed broadband services but has little access to search engine optimization tricks.