PHP Tools

Happy New Year!  For the start of the new year, I thought I'd review some of the PHP tools you should be learning, and using, to up your game in the coming year.

One of the challenges of a technical career is that your always wondering if you learn a new technology, if its going to be a waste of time.  You're constantly learning new things, and every time you're presented with the challenge of implementing something you've never done before you have to wonder if this technology will be around in another three years.  Technology moves that fast.

As you gain more experience in your chosen expertise, you get more selective in the tools your willing to spend time to learn.  Along those lines I thought it might be nice to do a light over view of where I see PHP tools at this moment in time.  These are the tools that I hear currently mentioned the most on the web, in workshops, and conferences.  In other words, the current tools of choice, and the tools you should seriously consider working with and learning.

First of all, we all should be using object-oriented coding.  PHP 5.3 is the way to go for now. The old procedural coding, for the most part, is dead.  I believe colleges are all teaching object-oriented now, so this is not a big deal.

Although, it seems MySQL is still the database of choice, I've seen a lot of use of two other databases you should be considering.  A file based SQLite.  It works great, and is super quick, except when you start to get into heavy transactions.  It's used to replace configuration and XML files, works great for mobile devices, and for small and medium size web site databases.

You might think that MySQL kicks in about then, but if you want to consider an alternative, I've been seeing the PostgreSQL database coming on strong.  For one thing, it's not Oracle controlled.  Oracle starts charging after you cross over a certain usage line.  It is the database of choice for raw speed doing complex tasks, like constantly displaying data for constantly updating weather monitors.

For JavaScript, hands down jQuery has been adopted universally.  Other tools I hear mentioned are Mootools, and Dojo.   For Ajax applications, I again hear jQuery.  jQuery has become so popular that is incorporated into a lot of PHP frameworks.

Speaking of PHP frameworks, there is a lot of buzz surrounding Zend Framework 2. The developers have reworked this PHP Framework to improve overall performance and take advantage of all the new features in PHP 5.3.  There has been an open forum during the development to get the best ideas from other PHP developers and implement them.  Consideration has been given to improving performance every step of the way.  The framework is currently in Beta release.  The documentation on the web on how to use this new release is starting to swell.  There are a lot of other good frameworks out there, but you should still spend some time to get to know ZF2, as its called, because of the extensive libraries of code available to ease your coding tasks.

Second, PDO and ORM for the database to PHP object type mismatch are important technologies.  You use PDO, for example, if you started with a MySql database and wanted to switch to the PostgreSQL database.  PDO makes switching databases easier.  ORM translates SQL database output to PHP objects for use in your application.  It makes coding database applications faster and easier with less problem in getting SQL queries correct.

There are many ORM options out there, however, the new Zend Framework 2 has settled on using Doctrine 2.  This makes Doctrine 2 the de facto standard to learn for applying PDO and ORM to your application, and make no mistake, don't let those SQL bigots get to you.  It is a benefit to code with an ORM.  Take it from me that has done it both ways.

A lot of frameworks now include testing components in the framework.  The testing component that is fast becoming the de facto standard is PHPUnit.  One new technology you should gradually start applying is unit tests.  The best way to start is to set up the testing environment, and write a couple of tests for your project, then gradually write a couple of more, expanding your test suite. Pretty soon you'll get the hang of it and it will become second nature.

For version control the current hot software is Git.  You should be using version control for all your projects.  Because Git is so popular, GitHub has become a mecca for releasing open source software, install Git, and join GitHub. Git runs on all platforms, if you haven't used version control software it's time to start.

For documenting your code you should be following the phpDocumentor syntax.  phpDocumentor has been the standard for a couple of years now.  My time spent learning how to document my code properly was well worth the time I spent looking over the phpDocumentor documentation.

Coding to a standard, so that all your code is written in the same format is good coding.  To help you check your code for syntax errors, and format your code for your custom style automatically, use PHP Code Sniffer.  This will also check your  CSS, and JavaScript. PHP Code Sniffer is installed through the Pear library.

Incidentally, if you're wondering what good code formatting looks like, I can recommend two references that I've run across.  One is on the web, in the Kohana framework documentation, and the other is in a book, "Advanced PHP Programming" by George Schlossnagle.  The important thing on code formatting is to choose a style and consistently use it in all your coding.

If you'd like a report on your code base, the number of lines of code, the complexity, the percentage of comments, number of classes, possible coding violations, bad practices with a bunch of other metrics.  The tool I hear mentioned is Sonar.

To build your application, run your test suite, and run every thing else with one command, like a "make" file, the application you want is Phing.

If you would like to automate several projects and run them on a schedule, "CruiseControl," will do that for you.  CruiseControl offers flexible scheduling, notifications, and integrates with Phing with a "PHP Under Control" plugin.

To solve your scaling problems for those web sites that start out small and get bigger really fast, and to get off of having to depend on your own hardware solution, or that of a commercial hosting company, there is a lot of good reasons to try out Amazon Web Services. There are other services out there, but Amazon stands way above all the others in features and pricing.

Don't get me wrong.  In each one of these categories other companies and developers have spent their time creating tools that do the same thing.  These other tools may be just as good, or even better.  I don't mean to put any of these other tools down.  All I'm suggesting is, at this moment in time, this is a tool you should consider spending your time learning, and that it probably would not waste your time.  If you prefer another tool, go for it, and let me know so I can take a look at it too.

Comments are closed.