WebProgrammingTalk Web Programming PHP
Introduction to CakePHP Hello There, Guest! (LoginRegister)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Introduction to CakePHP
09-25-2010, 02:57 PM,
#1
Introduction to CakePHP
Most technical books start by outlining the good features of the concerned technology, so that the reader is convinced that the technology is worth learning, and the book is worth reading. But unlike those books, this one starts with a warning: "Once readers have gone through the book, there will be no turning back! Web development will never be the same again. Developing a web application will become so easy, that it might make the readers very lazy. As a matter of fact, readers might even forget the basic syntaxes of PHP! And the word Cake will have a completely new meaning to them"

According to the official CakePHP website (http://cakephp.org): "Cake is a rapid development framework for PHP which uses commonly known design patterns like Active Record, Association Data Mapping, Front Controller and MVC. Our primary goal is to provide a structured framework that enables PHP users at all levels to rapidly develop robust web applications, without any loss to flexibility."

Someone who is new to frameworks might not understand parts of the definition. But understanding a few key terms will make the job much easier. A PHP framework is a collection of code, libraries, classes, and run-time environment that helps developers build web applications faster. The main idea behind using frameworks is to provide the developers with commonly used functionalities and a basic structure that they can build their application on. Most PHP developers, who have some experience, have their own set of libraries and structure to help them develop faster, as they can use their code base (and experience) from one project to another. But, building a web application on an open-source framework like CakePHP has its obvious benefits. By doing so, the developers not only use their own experience, but also the experiences of many other developers who have used and developed the framework. Also, the framework is much more reliable as it is used and tested by many application developers. Besides, using a framework like CakePHP has the advantage that all the developers involved in a project have to follow the same conventions and rules to structure the application. It makes it very easy for new developers to settle down if they are familiar with the conventions of the framework.

A design pattern is a general solution to a commonly occurring problem in web development. A design pattern is not a complete code, rather it is a description for how to solve a problem that can be used in many different situations. In web development, there are many common design patterns that are used to solve repeating and common problems. CakePHP has many of these design patterns integrated into it. Some of them are mentioned in the above definition: Active Record, Association Data Mapping, Front Controller and MVC. Among them, MVC, which stands for Model View Controller, is at the core of CakePHP. We will soon discuss MVC, and other important design patterns, in this chapter. The other design patterns will be discussed throughout the book.

The integration of common design patterns into CakePHP means that developers need not waste time in trying to solve problems that are commonly present in
almost all web projects. These are already solved in CakePHP! As a result, the developer can focus on the specific business logic of the application, rather than being busy in trying to reinvent the wheel. This results in much faster and rapid application development.

Though it is not mentioned in the definition, CakePHP works out of the box with both PHP4 and PHP5. So, as long the developer follows the CakePHP convention, their application will be easily portable between the two versions of PHP. Unlike many PHP frameworks, the developer need not worry about compatibility issues. Web servers with either PHP4 or PHP5 will gladly run CakePHP-based applications. But having said that, it is always a better idea to use PHP5 if compatibility is not an issue for the project. Since most CakePHP apps are custom applications, PHP4 compatibility is normally not an important factor. So, using PHP5 for CakePHP application is definitely recommended.

CakePHP is an open-source project and it is free for anyone who wants to use it. It is distributed under the MIT License. That means that not only will people be able to use it free of charge, but they will also be able to look at the source code of CakePHP, and find out how the magic works. Now, that we have a better understanding of the main concepts behind CakePHP, do have a second look at the definition! It should be much easier to understand. More importantly, we now have a good understanding of what to expect from CakePHP, as we now know what it is!

PHP is a wonderful programming language for server-side web development. One of its benefits is that PHP is very easy to learn. Any person with some basic programming skills (even without it) can start making dynamic web pages. PHP gives developers a lot of flexibility in the way that they code. In other words, it does not restrict the developer to follow a certain structure. This is also one of its major drawbacks. As inexperienced programmers start to built bigger applications, most of the time, the code becomes so unstructured that it becomes very hard to debug or modify even a small change. The same situation also occurs with experienced PHP developers, when the application becomes complex. The situation gets even worse, when multiple developers work in a single project, each following their own way of coding. The main reason for this problem is that PHP does not restrict the developers to follow a certain structure.

CakePHP helps to solve this problem by restricting the developers to follow a strict structure. By doing so, it makes sure that the overall code of the project has a structure that is easy to manage and maintain. The most important design pattern that CakePHP uses to maintain a structured code is the MVC (Model View Controller) pattern. The MVC (Model View Controller) pattern is a commonly used design pattern in software development, where the code is separated into three major parts: models, views, and controllers. The exact purpose of each part depends on the implementation, as it may vary from one framework to another. Here, we are going to describe the way CakePHP implements the MVC pattern. So, this is not a general discussion on MVC pattern, rather we are only going to see Cake's own MVC implementation. As we have already mentioned, CakePHP separates the code into three separate parts: models, views, and controllers.
Reply
12-03-2010, 02:08 AM,
#2
Re: Introduction to CakePHP
Wow couldn't read it all atm Sad
Ihost4you.com
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)
Contact Us | WebProgrammingTalk | Return to Top | | Lite (Archive) Mode | RSS Syndication