Learning to Bake

We recently just started using Cake PHP, and here is why!
On Thursday 24 March 2016

Spearline are currently developing some new products and features. As part of the new development we are looking into new technologies to use. I was responsible for investigating web frameworks that will provide a secure and efficient way to set up all of the backend administration for us and for our clients. The main reason why we are looking into using a framework is that development becomes a lot easier, faster and more efficient when using a framework. After careful consideration we decided that the framework that best suited our requirements was CakePHP!

 

Why CakePHP?

One of the major reasons we chose CakePHP over other frameworks like Laravel, Symfony and more, is that it is a rapid development framework which means we can get a site up and running pretty quick. The idea of CakePHP was to make developing applications fast using a software design paradigm known as “Convention over Configuration”. This approach reduces the need for additional configuration files, code consistency and maintenance but in that the developer must know the framework thoroughly. As we do not have any in house developer that is familiar with CakePHP this could be a disadvantage for us as there will be a steep learning curve for each developer at the start.

Ingredients

The software design pattern CakePHP uses is MVC. This allows our application to be separated into three main parts, the Model Layer, the View layer and the Controller layer. Each section has its own responsibility. The Model Layer is responsible for the handling of data which involves the processing and validation of data. The View layer is responsible for rendering of the data from the Model layer and creates a webpage containing data. Finally, The Controller Layer is responsible for handling requests from users so this interacts very much with the Model and View Layer. This is a big advantage to us. For example the developer who will be working on the User Interface can solely work on that without worrying about the logic behind the interface and vice versa as the Model and View do not depend on each other.

Also I found that the ORM is extremely helpful to us. ORM is a programming technique used in which a metadata descriptor is used to connect object code to a relational database. As our database has been recently redesigned (see our blog on MariaDB), by setting out the database schema we can connect tables that relate to each other quickly using CakePHP’s powerful ORM. This will simplify development because it will automate the object to table and table to object conversion which results in lower development and maintenance costs.

 Another amazing feature that CakePHP provides is the in-built libraries which are called Components and Helpers. These are functions that are shared between controllers which eliminates the need of carrying out repetitive and tedious tasks. For example the AuthComponent function automatically identifies and authenticates a user’s credentials on the application.  

Conclusion

From my experience with installing and connecting CakePHP to our database I was surprised at how quick and simple it was to get an application up and running. With a few minor adjustments to the code, I was able to view, add, edit and delete items from tables in our database through the CakePHP interface. Now I can see why CakePHP is very popular among PHP developers and why big companies like BMW, Hyundai and Sainsbury’s use it. Also, it has a large community to help with issues, bugs and just general inquiries, which is a big help when we are beginning to learn the framework. Weighing the pros and cons of CakePHP for our specific requirement, I think we have made the right decision that will benefit our company greatly.