04 November 2010

PHP Frameworks: What, When, Why and Which?

What is a PHP Framework?



PHP is the world’s most popular scripting language for many different reasons – flexibility, ease-of-use, among others – but often times coding in PHP, or any language for that matter, can get rather monotonous and repetitive. That’s where a PHP framework can help.


PHP frameworks streamline the the development of web applications written in PHP by providing a basic structure for which to build the web applications. In other words, PHP frameworks help to promote rapid application development (RAD), which saves you time, helps build more stable applications, and reduces the amount of repetitive coding for developers. Frameworks can also help beginners to build more stable apps by ensuring proper database interaction and coding on the presentation layer. This allows you to spend more time creating the actual web application, instead of spending time writing repetitive code.

The general idea behind the workings of a PHP framework is referred to as Model View Controller (MVC). MVC is an architectural pattern in programming that isolates business logic from the UI, allowing one to be modified separately from the other (also known as separation of concerns). With MVC, Model refers to data, View refers to the presentation layer, and Controller to the application or business logic. Basically, MVC breaks up the development process of an application, so you can work on individual elements while others are unaffected. Essentially, this makes coding in PHP faster and less complicated.

Why Should we use a PHP Framework?



Developers should utilize PHP frameworks for various reasons, but the number one reason is for speeding up the development process. Reusing code across similar projects will save the developer a substantial amount of time and effort. A framework offers pre-built modules for performing tedious coding tasks, so the developer can spend their time on developing the actual application rather than re-building the foundation with each and every project.

Stability is another big reason developers are utilizing frameworks. While simplicity is one of PHP’s greatest assets, and the reason many people prefer to use this scripting language, it can also be one of its biggest downfalls. It’s fairly easy, especially for beginners, to write bad code and not even realize it. With PHP the application will often times still work, but unknowingly you may have opened up a large security hole in your coding that may be susceptible to attacks. It’s important to remember that PHP is a very forgiving language, so it’s even more important to make sure to tie up any loose ends in your coding – even if the application seems to be working properly.

Finally, the availability of PHP frameworks is extensive, and there are many different frameworks to choose from. You can even create your own, although many developers elect to choose from any of the most well-known frameworks due to their popularity, large support teams, and their forums/communities that allow you to interact with other developers who utilize the same framework. As a side note, you should always examine your project to first decide if you should even use a framework or not. Some questions you should ask yourself are: Will it save you, and anyone else who may use it, time and effort? Will the app perform better? Will it improve stability? If you can answer yes to any of these questions, a PHP framework may be the right answer for that particular project.

When to use a PHP Framework?

This is a common question amongst experienced and beginner developers alike, and there’s really no direct answer to the question. For many beginners, a framework will offer greater simplicity as well stability, so it may be a good idea to use PHP frameworks whenever possible. It will help reduce or eliminate bad coding and speed up the build process.

On the other hand, many experienced PHP programmers see frameworks as tools for “weak” programmers that don’t understand how to write good, clean code. Whether this is true or not is up for debate, but the fact of the matter is that PHP frameworks are a tool that can be used to save time and tighten up one’s coding.
When working on a project with tight deadlines, utilizing a PHP framework is a huge benefit that can greatly speed up the coding process. So if you’re in a time crunch, PHP frameworks can be very beneficial to you. Another instance when PHP frameworks should be a consideration is when you’re working on projects with substantial amounts of monotonous coding, because it will help make the job much less tedious.

What to Look for in a PHP Framework?

There’s plenty of options available to anyone who may be searching for PHP frameworks, and there’s even the option of creating your own, although that’s only recommended for PHP experts. When searching for the the PHP framework best suited for your needs, it’s important to keep in mind who will be using and/or modifying your applications from top to bottom. If there are many people who will be using the application, it may be best use a popular PHP framework that many developers are familiar with. On the other hand, if you wish to build web applications for your own personal use, you are better off choosing any PHP framework that you’re comfortable with – whether it’s popular amongst the developer community or not.

Various factors to search for in a PHP framework include: easy of use, rapid development/performance, popularity amongst other developers, strong features, and support/forums. It’s recommended to try out several PHP frameworks when you’re first starting out in order to find one that suits your needs the best. All frameworks are slightly different and have varying strengths and weaknesses, for instance Zend Framework has been around since V3 and is full of features plus has an extensive support system in place since it has been around for so long. On the contrary, CakePHP is another PHP framework which is younger than Zend Framework and has slightly less of a support system in place (although support for this framework is growing rapidly), but is much more user-friendly and easy to use.

As you can see, each type of PHP framework has its own advantages, so it’s best to use a bit of trial and error to figure out which one will work the best for your needs. Another excellent way of choosing a framework is to consult your colleagues in the development community to see which ones they prefer. Those who have actually used a specific framework will be able to inform you of the ease-of-use, features, support availability, scope of the community surrounding the framework, and possible shortfalls.

Most Common Mistakes When Using a PHP Framework

Mistakes are possible in any type of programming, but PHP frameworks help to limit these mistakes greatly by providing good quality code that is tried and true from the start of the development process. Repetitive coding seems to promote mistakes now and then, and frameworks all but eliminate that problem.

That being said, there are still things to be careful of when utilizing any PHP framework. For instance, unless you are an expert in PHP programming, you should always opt for using a popular framework with plenty of support and an active user base (see below for examples of popular PHP frameworks). There are many frameworks out there that have little or no support, and/or they were created by individuals with limited knowledge of PHP. These types of frameworks can cause your applications to not function properly, and worse case scenario, could cause catastrophic security issues with your website.

Another somewhat common mistake is not ensuring your database and web server is compatible with the particular framework. For example, Seagull PHP Framework recommends the following configuration:

  • PHP: PHP 4.3.0 is the minimum, later versions work fine, as do versions PHP 5.1.1 and above. Avoid anything in the 5.0.x series
  • MySQL: MySQL 4.0.x, 4.1.x and 5.0.x are all supported. You can also use 3.23.x.
  • Apache: Seagull works fine with 1.3.x and 2.x series of Apache
If you don’t meet these requirements, you won’t be observing the best performance possible from your chosen framework. Even if you are an expert in PHP, you should always go over the documentation of the framework to confirm compatibility before trying it out.

Similar to the previously mentioned common mistake, not following the recommended installation process of your PHP framework can also give you some headaches. Take Seagull as an example again – the Seagull wiki has a detailed rundown of the framework’s installation process that has several key steps that are sometimes easily overlooked by careless or unsuspecting developers. The key is to take your time setting up the framework and follow the installation instructions to the “T” – The time you’ll save actually developing applications later will more than make up for the few extra minutes spent installing the framework correctly the first time.

What are the Best PHP Frameworks Available?

Within the past few years as PHP has evolved as the scripting language of choice by most developers, there have been an explosion of PHP frameworks to hit the scene. There is a great debate about what the best PHP frameworks are, because the simple fact is that not every framework is built for everyone. Here’s a quick rundown of five of the best and most popular choices right now:

Yii Framework

yii

Statistically, currently yiiframework is the best framework in the market. It’s a next generation PHP framework. The main features that makes Yii on top spot is its features and a bit faster than Codeigniter and Zend framework. Actually the markers of Yii have spotted some of those areas in existing frameworks and discovered new ways. For example, from the moment you install Yii, you get a perfectly functional and rather impressive website up and running – its all automatically. Yii also comes with a range of features for common tasks like CRUD (creating, reading, updating and deleting).

The Zend Framework

zend


The Zend Framework has a massive following amongst the development community and is focused on web 2.0 style applications. Because of their massive following, extensive support and active user base, Zend is referred to as “The PHP Company”. Zend is one of, if not, the most popular PHP frameworks available today. It has robust features that are built for corporate-level development, and it requires an extensive knowledge of PHP.

CakePHP

cakephp
CakePHP is a great choice for beginners to advanced PHP developers. It’s based on the same principles that Ruby on Rails is designed around, and it’s heavily focused on rapid development – making it a great framework to be used for rapid application development. Its rapidly growing support system, simplicity, and scalability make CakePHP one of the most popular PHP frameworks available today.

Symfony

symfony
Symfony is aimed more at advanced developers who’s main objective is to create enterprise-level applications – most notably Askeet and Yahoo! Bookmarks. This open source PHP framework is full of features and can do it all, but it’s main downfall is that it is a bit slower than other frameworks.

Codelgniter

codeigniter
 Codelgniter is well-known for its ease-of-use, performance and speed. Unlike Symfony, this PHP framework is ideal for shared hosting accounts or for when you want a framework with a small footprint. It offers simple solutions, and has an extensive library of video tutorials, forums, a user guide and wiki available for support. Beginners should consider using Codelgniter.

Seagull

seagull
Seagull is a well-established PHP framework used for building web, command line and GUI apps. It is an extremely easy to use framework that is ideal for beginners to advanced coders. For beginners, Seagull features a library of sample applications that can be customized to fit your needs, and for experts, Seagull offers a host of options – including best practices, standards, and modular codebase – for building web applications quickly and easily. Seagull has an active developer community and plenty of support documentation in place as well.

Kohana

Kohana Kohana is an elegant HMVC PHP5 framework that provides a rich set of components for building web applications. It requires very little configuration, fully supports UTF-8 and i18n, and provides many of the tools that a developer needs within a highly flexible system. The integrated class auto-loading, cascading filesystem, highly consistent API, and easy integration with vendor libraries make it viable for any project, large or small.

Summary

PHP frameworks are a great way for developers of all skill levels to reduce the need for repetitive coding, speed up the development process, and to ensure proper coding when creating web applications. This not only speeds up the development of rich applications, but it also tightens up PHP security by reducing the risk of security holes in your coding.

While some expert PHP coders do not feel the need to use frameworks to develop web apps, they can still be an advantage in situations where rapid development is necessary, such as under tight deadlines. And for beginner to intermediate developers, frameworks can enhance the PHP learning process while promoting good coding practices and reducing bad coding, which is common in PHP due to its “forgiving” nature.

There are many PHP frameworks available today, and thus developers are sure to find a framework that fits there needs in terms of features, support, speed, scalability and more. Some of the top PHP frameworks used by developers today include: The Zend Framework, CakePHP, Symfony, Codelgniter, Seagull and Kohana.

37 More Shocking jQuery Plugins


It’s really amazing to see what one can create using jQuery. Developers just don’t stop making incredibly interactive web applications every now and then. This post just demonstrates excellent examples of some of the best jQuery plugins out there.

jQuery Sliders

1) Slider Gallery- A similar effect used to showcase the products on the Apple web site. This ‘product slider’ is similar to a straight forward gallery, except that there is a slider to navigate the items, i.e. the bit the user controls to view the items. Simple stuff.
slider gallery


2) Accessible slider- Illustrations and code samples showing how to make a slider UI control accessible to those who aren’t running JavaScript or CSS.
Accessible slider


jQuery Manipulating Images

3) crop, labelOver and pluck-Crop-Gives your visitors the power to crop any image on the fly using JavaScript only. Also there are 2 other plugins: LabelOver and Pluck.
crop image

  • Live Demo Of Crop: Here
  • Live Demo of LabelOver: Here

4) Semitransparent rollovers -A simple method for enabling semi-transparent rollovers which actually work on IE 6.
Semitransparent rollovers

  • Live Demo Of Crop: Here

5) Creating A Sliding Image Puzzle Plug-In- Creates sliding-image puzzles based on containers that have images. Running the demo page we get this output in the image below:
Creating A Sliding Image Puzzle Plug-In


jQuery Navigation Menus

6) Digg Header- This is a replica of the Digg header. Fluid width (but only to a point!), drop down menus, attractive search, easy to change colors… There is a lot of smarts in a small place in this example!
jQuery Navigation Menus digg menu


7) IconDock- a jQuery JavaScript library plugin that allows you to create a menu on your web like the Mac OS X operating system dock effect one.
icon dock


jQuery Accordions

8 ) Horizontal Accordion- This plugin provides some simple options to alter the accordion look and behavior.
jQuery Accordions


9) HoverAccordion- A jQuery Plugin for no-click two-level menus.
jQuery hover Accordions


jQuery Image Viewer

10) Step Carousel Viewer- Displays images or even rich HTML by side scrolling them left or right. Users can step to any specific content on demand.
Step Carousel Viewer


11) Featured Content Glider- You can showcase new or featured contents on your page, by turning ordinary pieces of HTML content into an interactive, “glide in” slideshow. Supports two different display modes- “manual” and “slideshow.”
Featured Content Glider


jQuery Charts

12) jQuery + jFlot - Plots, Canvas and Charts.
jQuery Charts  Plots, Canvas and Charts


13) Accessible charts using canvas and jQuery – A proof of concept for visualizing HTML table data with the canvas element by using jQuery to provides several types of editable graphs, such as Pie, Line, Area, and Bar.
charts using canvas and jQuery


jQuery Editors

14) Small Rich Text Editor - Small footprint, Cross-browser, Ajax Image upload, HTML Cleanup with PHP back-end rich text editor with all basic Rich Text functionality included.


15)markItUp! Universal markup editor- This plugin allows you to turn any textarea into a markup editor. Html, Textile, Wiki Syntax, Markdown, BBcode or even your own Markup system can be easily implemented. Worth Checking!


jQuery Flash Plugins

16) jQuery Flash Plugin- A jQuery plugin for embedding Flash movies.


17) jMP3- jMP3 is an easy way make any MP3 playable directly on most any web site (to those using Flash & JS),

using the sleek Flash Single MP3 Player & jQuery.

18) jQuery Media Plugin- It can be used to embed virtually any media type, including Flash, Quicktime, Windows Media Player, Real Player, MP3, Silverlight, PDF and more, into a web page.

jQuery Tabs

You can use the a href=”http://docs.jquery.com/UI/Tabs”>jUI/Tabsto create more dynamic tab functionality.
19) jQuery Tabs- Typical tabbing structure which degrade nicely without JavaScript enabled.


jQuery LightBox

20) Fancy Box- Kinda different image zooming script for those who want something fresh. Features: Automatically scales large images to fit in window, adds a nice drop shadow under the full-size image, image sets to group related images and navigate through them

21) Thickbox Plus- Click an Image to view a ThickBox image that is resized when your window is resized to fit the window.

jQuery Datagrid plugins

22) Flexi Grid- Lightweight but rich data grid with resizable columns and a scrolling data to match the headers, plus an ability to connect to an xml based data source using Ajax to load the content. Similar in concept with the Ext Grid only its pure jQuery love, which makes it light weight and follows the jQuery mantra of running with the least amount of configuration.


23) Query Grid 3.1- Datagird plugin for jQuery, where the user can manipulate the number of requested pages with adding, updating, deleting row data.


jQuery Field Manipulation

24) FaceBook Like – jQuery and autosuggest Search Engine- This autosuggest search engine is inspired from facebook for design,

use jQuery as ajax framework and BSN Autosuggest libs.

25) Masked Input Plugin- It allows a user to more easily enter fixed width input where you would like them to enter the data in a certain format (dates,phone numbers, etc).

jQuery with cool animation Effects

26) jQuery Enchant- Devoted to rich effects. It already features all effects you know from scriptaculous/interface, as well as many more great additions: color animations, class animations and highly configurable effects.

27) EasyDrag jQuery Plugin- Add the ability to drag and drop almost any DOM element without much effort. So it’s simple to use and you can also attach handlers both to the drag and to the drop events.

28) Simple Effects Plugins- Nice animation effects that can easily toggle, hide, show, fade, slide elements.

29) Slide out and drawer effect- A demonstration of accordion effect in action, where the mouse settles on the title of the ’section’ and the associated links are exposed. What makes this effect particularly cool, is that the drawers maintain a fixed height and slide between restricted area.

jQuery Worth Checking Plugins

30) crop, labelOver and pluck- How to create a drop cap and apply it to every paragraph in a DIV.

31) Style Author Comments Differently with jQuery- Nice custom styling applied to comments left by the author.

32) Creating a fading header- A simple example using jQuery and CSS that shows you how to create the fading header technique.


33) Coda Bubble- A demonstration of the ‘puff’ popup bubble effect as seen over the download link on the Coda web site

34) Another In-Place Editor- This is a script that turns any element, or an array of elements into an AJAX in place editor using one line of code.

35) jQuery Taconite- The jQuery Taconite Plugin allows you to easily make multiple DOM updates using the results of a single AJAX call. It processes an XML command document that contain instructions for updating the DOM.

jQuery Web Applications

36) GenFavicon- A cool online generator that creats little favicons used throughout the web. You have the option of either specifying a URL for the image you’d like to convert or uploading it to the site for processing.

37) WriteMaps- WriteMaps provides an easy-to-use interface for creating, editing, and sharing your sitemaps.