Monday, September 14, 2009

Overview of few PHP Frameworks to choose from

What is a framework and why to use a framework? 

A framework is "A structure supporting or containing something". Frameworks give us a structure to work within with lots of functionality build in. For ex. A database abstraction layer.

Frameworks help us avoid re-inventing the wheel again and again. It also enables rapidly develop an application. Some of the advantages of using a framework are : modularity, anticipation of change, abstraction, low coupling, and high cohesion (all the properties that styles aim at). 

List of Frameworks to choose from - 

1) CakePHP - A rapid development framework for PHP that provides an extensible architecture for developing, maintaining, and deploying applications

2) ZendFramework - Zend The PHP Company..! The framework from Zend itself which is open source. It is quite loosely coupled and framework don't force you to follow any coding standards. You can continue with your own convention and still use Zend.

3) Symphony - Almost a 2year old project. Quite rich documentation and user community

4) CodeIgniter - Easy to start with. It is easier for someone who is just starting with MVC and PHP. It's got good Documentation and quite comprehensive User Guide.

5) Kohana (Smaller footprint of CodeIgniter) - Extremely lightweight MVC framework

6) Prado - is a component-based and event-driven programming framework for developing Web applications in PHP 5. PRADO stands for PHP Rapid Application Development Object-oriented.

7) Agavi - Agavi is a powerful, scalable PHP5 application framework that follows the MVC paradigm. It enables developers to write clean, maintainable and extensible code. Agavi puts choice and freedom over limiting conventions, and focuses on sustained quality rather than short-sighted decisions.

8) Rapyd - a minimalistic and rapid PHP framework. 

9) ELF PHP - Extra Light PHP Framework 

10) BaseApp - Simple, Small & Swift

11) SuitFramework - SUIT (Scripting Using Integrated Templates) is an open-source templating framework that allows you to define your own syntax through nodes. It is available in both PHP and Python. It is extremely lightweight, yet powerful.

12) Madeam - Madeam is a PHP framework for small agile teams and freelancers.

A good site to checkout before choosing a framework - http://www.phpframeworks.com/ 

Lastly, a good article on No-Framework PHP MVC Framework

Tuesday, September 8, 2009

Username as subdomain on windows

While working on http://designerscouch.org worked on allowing users to have usernames as subdomains.


All went well on the server. But when I was trying to run the codebase on my local machine which had Apache2 running on windows I was not able to browse the site. After some research on the net and trials and errors succeeded in running the codebase on loacl machine.

Steps to set up named subdomains using Apache on Windows platform.

1) Open up your httpd.conf file in a text editor (wordpad or notepad) and add the following line at the bottom of the document.

Include conf/hosts.conf

The file, from the default installation can be found in the X:\Program Files\Apache Group\Apache2\conf folder.

Save the file.

2) Now create the hosts.conf file. Using your text editor create a new document and copy the virtual host example that is commented out in httpd.conf.

#NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
#
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot /www/docs/dummy-host.example.com
# ServerName dummy-host.example.com
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
#

Uncomment the text, remove the #’s and change to fit your need. In the example below there are settings on a made up domain name, localhost.com.

<VirtualHost *:80>
ServerAdmin admin@localhost.com
DocumentRoot "X:/Program Files/Apache Group/Apache2/htdocs"
ServerName *.localhost.com
ServerAlias *.localhost.com
</VirtualHost>
The above configuration allows you to put “anything” before the domain provided that the host exists in your HOSTS file.
Save the file as hosts.conf in X:\Program Files\Apache Group\Apache2\conf.

3) Now we modify the hosts file on windows OS to inform which hosts exists -

The HOSTS file is usually located in %SystemRoot%\system32\drivers\etc folder.
Open the file with a text editor and then add the following to match your virtual host settings above.

# PC (LOCAL)
127.0.0.1 localhost.com
127.0.0.1 www.localhost.com
127.0.0.1 suchetal.localhost.com
127.0.0.1 username2.localhost.com

Save the file and restart Apache. You should then be able to navigate to any of the URLs listed above.
Ex: http://suchetal.localhost.com