10 Principals of PHP Development

PHP Logo

Are you a PHP developer? Go read the article ‘10 Principles of the PHP Masters‘. Do you want to learn PHP? Go read it.

With PHP’s widespread adoption,it’s almost too easy to find a script or snippet to do exactly what you need. Unfortunately, there’s no filter as to what is a “good practice” and what’s, well… not so good when writing a PHP script. We need trustworthy sources, who have proven they have a solid grasp on the best practices of PHP.

Use PHP Only When You Need it

Rasmus Lerdorf

PHP was designed for Web Development – and its very good at it. Just because you can use it to create desktop apps don’t mean that you have to.

Use Many Tables With PHP and MYSQL for Scalability

Matt Mullenweg

This advice comes from a rather controversial database design choice he made when creating WordPress MU. It created separate tables for each blog rather than the usual method.

Never, ever trust your users

Dave Child

Validate everything that comes from the user. Yeah, I know its boring – but it must be done.

Invest in PHP Caching

Ben Balbo

Caching is very important if you have a busy site.

Speed up PHP Development with an IDE, Templates and Snippets

Chad Kieffer

I find it a bit hard to support this. Yeah IDEs speed up development – a small bit. About Snippets – use them if you trust the source.

But if you really want to speed up development,

  • Use a framework(coming up later)
  • Invest in code generation.

Make Better Use of PHP’s Filter Functions

Joey Sochacki

This is actually new to me – but I am going to try this out.

Filtering data. We all have to do it. Most, if not all of us, despise doing it. However, unbeknown to most are PHP’s filter_* functions, that allow us to do all sorts of filtering and validation. Using PHP’s filter_* functions, we can validate and sanitize data types, URLs, e-mail addresses, IP addresses, strip bad characters, and more, all with relative ease.

Use a PHP Framework

Josh Sharp

This is one thing that really speed up development. Also, the programmers that have to maintain your programs will thank you for it.

Don’t use a PHP Framework

Rasmus Lerdorf

The basic argument is that Frameworks slow things down. Keep that in mind when your choosing a framework.

Use Batch Processing

Jack D. Herrington

This refers to the tasks that can processed in the background – Herrington recommends using batch processing and cron here. As most of you are aware, PHP don’t have threads – and it don’t matter to me. You don’t use threads when serving a web page. But in cases like these, threads come in handy.

My advice? Use Python or some other language that has threads to do do the job for you – you don’t have to do everything in PHP.

Turn on Error Reporting Immediately

David Cummings

This is very important when developing the app – error reporting lets you find future bugs. Make sure they are on.

And just as important is the fact that you should turn them off in the production system – you don’t want your users seeing your error messages.

Related Links

About Binny V A 102 Articles
Freelance Web Developer on the LAMP Platform. Maintains a blogs http://blog.binnyva.com/. Other sites include Bin-Co and OpenJS

5 Comments

  1. The advice I can give is to use a framework if your project is a medium or large project. For small projects, frameworks are not necessary. And for very large projects, it MIGHT be better to create your own framework for it.

  2. yes…I agree with you if the project is big then it’s better to use framework….and I recommend using any available MVC framework of PHP like CakePHP, Zend Framework or CodeIgniter for reducing development time…

  3. NeDon’t use a PHP Framework

    Rasmus Lerdorf

    The basic argument is that Frameworks slow things down. Keep that in mind when your choosing a framework.

    This is perfectly a blunder………!

Leave a Reply to Roshan Bhattarai Cancel reply

Your email address will not be published.


*