| Country Rank: | 12 |
|---|---|
| World Rank: | 49 |
| Profile Viewed: | 969 |
| Points: | 9069 |
|
16 Jan
2010
|
PHP MVC framework
By: Wesam Azmy
|
Development of PHP scripts without a preconceived plan to manage them is asking for a headache. The goal of a framework is to make the process of writing web-based applications simpler.
An application designed around MVC is easier to manage because it is split into tiers, which allow for independent development. This promotes code reusability by building models, which are reusable throughout the application.
What makes a good framework?
A good framework is easy to learn, simple to use, intuitive to work with, easy to extend or to modify, rapid to build (maintain) applications with and of course stable.
1- Clean and simple design
* HTML should look like HTML
* Keep the PHP code in the views extremely simple: function calls, simple loops and variable substitutions should be all you need
2- Secure
* Input validation using pecl/filter as a data firewall
* When possible, avoid layers and other complexities to make code easier to audit
3- Fast
* Avoid include_once and require_once
* Use APC and apc_store/apc_fetch for caching data that rarely changes
* Stay with procedural style unless something is truly an object
* Avoid locks at all costs
Clean separation of your views, controller logic and backend model logic is easy to do with PHP. Using these ideas, you should be able to build a clean framework aimed specifically at your requirements instead of trying to refactor a much larger and more complex external framework.
Many frameworks may look very appealing at first glance because they seem to reduce web application development to a couple of trivial steps leading to some code generation and often automatic schema detection, but these same shortcuts are likely to be your bottlenecks as well since they achieve this simplicity by sacrifizing flexibility and performance. Nothing is going to build your application for you, no matter what it promises. You are going to have to build it yourself. Instead of starting by fixing the mistakes in some foreign framework and refactoring all the things that don't apply to your environment spend your time building a lean and reusable pattern that fits your requirements directly. In the end I think you will find that your homegrown small framework has saved you time and aggravation and you end up with a better product.
CodeIgniter is a powerful PHP framework with a very small footprint, built for PHP coders who need a simple and elegant toolkit to create full-featured web applications. If you're a developer who lives in the real world of shared hosting accounts and clients with deadlines, and if you're tired of ponderously large and thoroughly undocumented frameworks