Thursday, September 11, 2008

10 Principles of the PHP Masters

1. Use PHP Only When You Need it

PHP was created out of a need to solve web development problems. However, you can't use PHP for everything. PHP is a just like a tool in your toolbox, and that even PHP has limitations. Trying to use PHP for everything isn't efficient, and it certainly isn't the best use of your time as a web developer. Don't be afraid to to use other languages if PHP isn't working out for your project.

2. Use Many Tables With PHP and MYSQL for Scalability
3. Never, ever trust your users
4. Invest in PHP Caching
5. Speed up PHP Development with an IDE, Templates and Snippets
6. Make Better Use of PHP's Filter Functions
7. Use a PHP Framework - Josh Sharp

There has always been a debate as to whether to use a PHP framework like Zend, CakePHP, Code Igniter, or any other framework. There are upsides and downsides to using one, and many developers have their own opinions about whether or not to go down this road.

Josh Sharp is a web developer who makes his bread and butter creating websites for clients. This is why you should trust him when he says it's a good idea to use a PHP framework to save time and eliminate mistakes when programming. Why? Josh believes it's because PHP is too easy to learn.
But PHP's ease of use is also its downfall. Because there are less restrictions on the structure of the code you write, it's much easier to write bad code. But there is a solution: use a framework.
PHP frameworks help standardize how you program, and can save lots of time in the development process. You can read more about the benefit of using a PHP framework at Josh's blog.

8. Don't use a PHP Framework - Rasmus Lerdorf

Contrary to Josh's belief that one should use a PHP framework, Rasmus Lerdorf, the Godfather of PHP himself, believes that frameworks aren't that great. Why? Because they perform much slower than simple PHP.

During Rasmus' presentation at Drupalcon 2008(http://szeged2008.drupalcon.org/), Rasmus compared the response times to a PHP page with a simple "Hello World" example, and compared it to a few PHP frameworks (http://talks.php.net/show/drupal08/24 - slides 24-32), and showed that PHP frameworks are much slower than straight PHP.

You can listen or watch the entire presentation where Rasmus shows the performance losses with PHP frameworks. In short, Rasmus shows that performance takes a major hit when you use a PHP framework as opposed to using pure PHP.

9. Use Batch Processing
10. Turn on Error Reporting Immediately

Source :- http://nettuts.com/articles/10-principles-of-the-php-masters/