Freelance PHP Developer

CakePHP 3 - My First Thoughts

23rd January 2014

I took the time tonight to review the preview release of CakePHP 3.  Having used CakePHP for 6 years, I had certain expectations about what I wanted from the Framework.  The leap from version 1 to 2 had been to improve things that perhaps version 1 hadn't got quite right - particularly improvements when it came to speed.  But other than the improvements, the core way that the framework worked was similar - the learning curve from version 1 to 2 wasn't that step.  So with eager anticipation, I began with CakePHP 3.

The installation of CakePHP 3 was very simple.  I was new to Composer, but it was very easy to use, and even set the permissions on my tmp directory - fantastic start.

From there, I was able to set up my database details no issue in the app/Config/app.php file (which for coders familiar with CakePHP 2, is a combined file of the core.php and database.php).  While my personal preference would have been to call the file config.php, I liked the idea of merging the two files.

I created my controller file, and perhaps out of habit more than anything, immediately went to type $this->Model->find();  This was when I realised things were different.  I knew CakePHP 3 was going to have a new ORM, and I know things are still only in the preview stage, but I do have some concerns with the way it works.

The first change is that when calling a model, CakePHP3 uses the plural model name rather than the singular. This will be a big change for programmers used to calling their model in the singular name.

After a bit of confusion, I managed to get my line of code to look like this:

$articles = $this->Articles->find()->first();

While perhaps a little more code than under CakePHP 3, my main concern was the speed.  It was slow.  That query alone look a few seconds and I only was only fetching one record.  I am assuming this is because the ORM is still being developed, or the way of doing the find query has just been done incorrectly - or I am putting the code in the wrong place! I have placed a ticket regarding this and will update when I get an answer.

6 May 2014 - Update - I reported the issue (with my old GitHub account) and the slowness issue has been since fixed.  Read about this here.

I will comment again on the next realise and as the documentation gets updated.  My hope is to gain an early understanding of the new framework so that I can actually help write and develop a lot of the documentation - and try to make it as simple as possible.  My only hope is, that the new ORM keeps a lot of the simple concepts from CakePHP 2 and CakePHP 3 doesn't try to change something too radically that so many developers have enjoyed for many years.

Did you know, I am now offering FREE mentoring for those looking to get into freelancing.
Whether you are looking to join Toptal or break into freelancing...
Click here to learn more about my Mentorship Program.