Day 1 – What you should know about cakephp

Before starting out CakePHP you should know what it is and where it should be used? We will discuss few question on our first day so that we can make clear understanding of it use cases where it fits and where it does not fit.

 

 What is CakePHP?

According to CakePHP official book

CakePHP is a free, open-source, rapid development framework for PHP. It’s a foundational structure for programmers to create web applications. CakePHP primary goal is to enable you to work in a structured and rapid manner–without loss of flexibility.

So, that means if you required to build a web application than you can start doing it with CakePHP. as it will give you a head start in web development. but, what about other ready made cms or application like WordPress®, Joomla®, Drupal® etc. Well, that depends on the type of web application development you need. For  e.g. if you really need to create yet another blog site or CMS then go for existing application as they have large community support and fully matured which will give you a real head start. But then, it isn’t always a CMS or blog that you need. what if you need a back-end service for your existing application or you want to create a enterprise web application or mobile application back-end.  Other CMS will fail as they are being designed for a particular area to address and implementing your own solution will be much faster then to have one of them. Here, CakePHP will come to rescue you.

So, lets condense some points:

  1. CakePHP is a Web development framework written in PHP not an full fledged application.
  2. Good for creating something custom where existing applications fail to deliver.
  3. It provides guidelines to application developer with robust architecture to concentrate on business logic and not to reinvent basic architecture (that is where it is considered fast).

Basic skills needed for CakePHP

  1. Atleast basic knowledge of PHP specially OOPS concept.
  2. Understanding of MVC architecture. (just google it and you will have thousands of pages about it).

and that is all and don’t be afraid we will discuss some of the points above in detail in next post.

CakePHP doesn’t require anything else but as a web developer you need to learn or should at least have basic idea of other technologies to fully develop any web application. for e.g. Javascript, CSS, SQL, HTML etc.

Assuming that you have required basic skills let’s get started with Learning CakePHP :)

MVC architecture

MVC stands for Model View Controller. According to wiki

Model–view–controller (MVC) is a software architectural pattern for implementing user interfaces. It divides a given software application into three interconnected parts, so as to separate internal representations of information from the ways that information is presented to or accepted from the user

Yeah, I know above definition helps a lot 😉 anyway let’s try to put it into simpler words with an example. Suppose, you are going to your favorite coffee shop and order something. Now, you sit on a nice table and wait for your coffee and after a minute or so you get your coffee nicely in a cup or whatever. Here are some key points that i like to mention:

  1. You ordered expresso coffee at counter now, let assume this counter act as a controller who does not let his clients to go beyond a specified area and tell client to wait untill the order is processed.
  2. Then, Your order as a slip is processed at backend where let say expresso coffee acting as a model which has some special ingredients specific to coffee shop which are not exposed to you.
  3. You don’t need to have ingredient list before having it as the end result is a processed coffee with presentable view

I know this example is very bad but really at heart MVC framework works like that:- The client (mostly a browser) requests for a page (basically a model which is associated by it’s view) to a controller and then controller asks for model for information and the information is then given back to client in a presentable view.

MVC Architecture image

Advantages of MVC Architecture

  1. It helps you to organize code. You have all data related operations in Model, presentational in View and controller logic in Controller (later you see that CakePHP has special directory assigned to them).
  2. Single entry point to your application logic. All your request will be handled by front controller. it helps you in reducing redundant code in application for generic operations like showing application header, menus etc. imagine having to insert code in each and every php file of a traditional architecture where for e.g. about.php will have a physical location and you have to make some generic operation again and again for every file. This can easily becomes difficult if not impossible to maintain the code. This particular thing is known as agility of code. MVC Architectures are agile whereas other is not.
  3. Modulus Approach: MVC gives you opportunity to make your code modulus in nature. You can develop an application which can expand on need.
  4. Easy Development of Views: with MVC because your views are in seperate files it’s easy to recreate a theme from ground zero compare to traditional approach.

Benefits of using MVC is not limited to above stated points. you will get to know more advantages as we will proceed.

 Disadvantages of MVC Architecture

Every good thing comes with a price and also if you are going for CakePHP there are some if none disadvantages also.

  1. Need to know more than basic PHP for advance application development. Some of the things like PDO may have steep learning curve.
  2. You have to learn about CakePHP conventions. Yes, it’s not a magic you need to know before you can use it.
  3. For smaller 4-5 web pages, may be it’s easy to go conventional. May be, you don’t even require PHP.

For now i need you to go and read some more about architecture and it’s advantages and disadvantages. We will continue Learning CakePHP in Day 2.

If you have some suggestions please feel free to comment. Thanks and have a nice day.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>