Longer ago, but I never mentioned it, I also finished up Matthias Noback's Style Guide for Object Design which I got from his website and now also has been picked up a publisher, so it's now available here as Object Design Style Guide. This is specifically about php and was also quite excellent. His style guide bears a lot of similarities to how we handle our php at my job, so it was familiar and relevant. It's a book I feel like I could revisit, reread, and learn more. One thing he recommends that I don't do heavily in my code is throwing exceptions for invalid property values. I end up doing a lot of checking a variable (Is the id > 0? Does the input for this email address field look like a real email?) and then returning an error response. Or if the code fails to find a requested object it returns null and then if the object var is null, an error response is returned. Noback throws different types of Exceptions in his class instead. I can see how, for instance just throwing some kind of "InvalidInputException" which a message like "Email address is invalid" would allow my routing code to just catch that type of exception and send a response with the appropriate http status code and message. That way my individual controllers would not need to account for all the various invalid inputs as specific if blocks.
[View full entry]