There’s always a bridge between textbook knowledge of programming – syntax, procedure etc. – and the real world knowledge that you get from actually developing real applications. Here are five things every PHP developer should be familiar with before they begin developing web applications in PHP.
Frameworks are arguably one of the most important areas of PHP development. With no single accepted way of developing web applications in PHP, a number of open source frameworks are available, helping you code quicker, more consistently and more effectively. Some of the best include CakePHP, Symfony and CodeIgniter. A lot of the frameworks also follow the MVC design pattern, which you should definitely be familiar with should you ever have to work on code that follows it. After a while, you may even feel inclined to create your own framework to meet your needs.
2. Templating engines
If you’re not using a framework that enforces a specific design pattern, chances are you want to be using a templating engine. Whether you create your own or using one of the existing options (like Smarty), a templating engine allows you to entirely seperate your code logic from your HTML interface code (and associated CSS/JS/etc.). This considerably simplifies your code, allows quick and easy modifications to the actual front-end of your application, and makes it easier for non-developers to modify your application’s visuals.
3. Code availability
As I mentioned in a previous post, PHP has some of the best code availability of any language. From various snippet archives to entire class databases, PHP developers are really spoilt for choice when it comes to reusing existing code. In fact, you can almost get away with building an entire application without writing a single line of code.
4. Don’t reinvent the wheel
This might seem fairly obvious, and a little part of the previous point, but very few PHP developers realise how much power is already available as part of PHP itself. Forget pulling in new libraries, or writing long complex code routines – first take a look at the PHP manual. For example, have you ever heard of number_format(), parse_url(), wordwrap() or bbcode_parse()? Take a look at the entire function reference, pick a category and have a browse – you’re bound to find something new.
5. IRC is a wonderful thing
For when you’re stuck on a complex problem that you just can’t make sense of, hop on IRC. The ##php unofficial support channel on Freenode is always full of experienced PHP developers happy. You’ll need an IRC client – ChatZilla is great if you’ve got Firefox – and a little patience; when you need help, pastebin your code and head to irc://irc.freenode.net/php. Post your question and wait patiently; some kind soul (or multiple kind souls!) will answer. When you’ve finished, consider lurking in the channel to help others with their problems. No man is a mountain, especially with PHP’s enormous library of functions; on IRC, the pool of collective knowledge can solve just about any problem.