CakePHP Tips 2017 Part 1


Whoops as ErrorHandler I recently switched to Whoops in my apps. It provides a better exception rendering for development mode for most cases. Just load the plugin (dereuromark/cakephp-whoops) and modify the bootstrap line: //(new ErrorHandler(Configure::consume(‘Error’)))->register(); (new \CakephpWhoops\Error\WhoopsHandler(Configure::consume(‘Error’)))->register(); If you already…

CakePHP Tips Winter 2016


This is literally my last blog post for the year 2016 🙂 Use the right DateTime typehint If you are passing DateTime objects around in CakePHP, they are usually Chronos objects, and either \Cake\I18n\Time or \Cake\I18n\FrozenTime then. Both those are…

Emoji and CakePHP


You might think: Why do I care. Well, you would be surprised – but pretty much any website with at least one form on the page will be affected here. So anyone with even just a basic contact form should…

CakePHP Tips Fall 2016


Always use proper version check method Be aware of version checks that are using the inferior and even wrong </> comparison. This can lead to wrong conditions with higher minor versions. I had this in my code from the early…


Chronos – Let there be time


In PHP most know of DateTime class to handle date and time. At least with more modern PHP versions it is now not advised anymore to use the plain old date() and time() functions. The use cases – especially with…


Use isset() and empty() wisely


This is another part of the series "How to write better PHP code". Sometimes it is the small things than can make all the difference. In this case simply using the correct way of checking for variable content can avoid…