Coding guidelines

When you are coding for the Zend Framework, or even with the Zend Framework, it is expected that you will follow certain guidelines. These are designed to make group projects easier. In other words, by defining coding conventions, you will not only avoid problems later but you will also make it easier for others to read your code. The Zend Framework documentation includes several pages of guidelines, including:

  • Make sure the files are clean. In other words, no leading or trailing spaces that can call a web server to unexpectedly send content before headers, standard indents of four spaces, etc.
  • Start your class name with Zend_ if and only if it is intended to be part of the Zend Framework itself, rather than just an application that uses the framework.
  • Underscores are forbidden in function names. Use camel-style lowercase (as in getTodaysDate()), instead.
  • Start your variable names with an underscore only if they are private or protected.
  • Declare all variables as private, protected, or public. Don’t use var.
  • Use the standard PHP tag, as in <?php ?> — not the short form (<? ?>).
  • Make sure your code is easy to read. In other words, when you use a period (.) to concatenate text, be sure to put spaces before and after the period to make it more readable. The same holds for adding spaces after commas when declaring an array.
  • If you must pass-by reference, do it only in the declaration of a function. Call-time pass-by reference is prohibited.
  • Every PHP file must include documentation that can be read by PhpDocumentor, and the coding guidelines specify certain minimum tags.

This is not a complete list of guidelines, of course, but it should give you an idea of the types of requirements. Check the documentation for the full list, so your code more easily fulfills the promise of making PHP projects easier to share.

Leo Dan Hall

Smiles

Clouds of despair
Shadows of loneliness
The chill of sadness
That cover the landscape of our lives
Are lessened with a smile
Just as sun warms
Frosty hill and shadowed valley,
The sunshine of a smile warms
A heavy heart
With soul-shine

A smile, more of eye
Than upturned mouth,
Says, I know, I understand, I care,
Caring soul-shine

A simple smile, almost not there,
Says, share with me, quietly,
Feel with me, softly,
Enjoy with me, calmly
Glowing soul-shine

A smile, upturned wide,
Says, laugh with,
Run with me,
Have fun with me.
Boisterous soul-shine

A smile, at first hesitant or shy,
Says, shouldn’t we be friends
Get to know me,
Grow with me.
Knowing soul-shine

Any smile –
Caring, glowing, boisterous, knowing–
Freely given, blesses me then,
But a smile returned
Blesses me and thee–again.
Reflected soul-shine

Author: Leo D Hall

20120324-095736.jpg

20120324-095134.jpg