Golden Rules of Professional PHP Coding

June 12, 2011
by Julian

1.  Always use in development and in staging highest error reporting level, and display_errors ON:

error_reporting(-1);
ini_set('display_errors', 1);

2. Fix every warning or notice that occur.
3. Check regularly server’s error_log for notices/warnings

4. Identify any temporary hack with a special mark. Maybe something like:

#@TODO masterpiece by @smartguy, to quick fix the division by zero

 

5. Each function must do a single task. If is log in the user and record the login in stats table, be nice and create a separate function for ‘record the login’ stuff.
Maybe even a distinct class for stats ?

6. Use a version control system. SVN is NOT dead.

7. Use an IDE Aptana 2, Aptana 3, Eclipse, even Zend Studio .

8. Know your IDE: code snippets, code assist, integration with Zend Framework, SVN integration, bug tracker integration, and so on

This entry was posted in Best Practice. Bookmark the permalink.

3 Responses to Golden Rules of Professional PHP Coding

  1. Todd September 28, 2011 at 11:49 am

    Seriously? There’s not even a hint of unit testing here. To be professional, you have to use an IDE, but you don’t have to test that your classes work?

  2. Julian September 28, 2011 at 12:00 pm

    Oh, unit tests are at a different level. A different story

  3. Daniël November 24, 2011 at 6:23 pm

    You forgot about one of the most important rules: “never trust user input”.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>