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…
Year: 2016
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…
Templated emails in CakePHP
Quite a few years ago I wrote small wiki note about templated emails and inline images/CSS. I never really got around to blog about it, let alone covering the 3.x version of it. There was a ticket opened recently regarding…
CakePHP and connecting to GitHub API
I had to write a small tool to automate releasing certain GitHub repositories, and for that to authenticate I had to connect to GitHub API. The integration wasn’t super-easy as there was no documentation yet on how this could be…
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…
Use 3.x Migrations for your 2.x CakePHP app
In this post I reveal one of my tricks on how to leverage 3.x power in a legacy 2.x project. You might have already read on how to use some of the splits, like the ORM, in 2.x projects. Today…
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…
Developing CakePHP 3+ Plugins, it’s fun!
It is fun – and it should be! The days of CakePHP 2 plugins and how difficult it was to actually develop plugins are over. Back in the days (OK, I still have to do it once in a while),…