Understanding Model-View-Controller - 1.3 - CakePHP cookbook [PDF]

Programming using MVC separates your application into three main parts: The Model ... Figure: 1 shows an example of a ba

7 downloads 8 Views 1MB Size

Recommend Stories


[PDF] Download Electronics Cookbook
The greatest of richness is the richness of the soul. Prophet Muhammad (Peace be upon him)

Raspberry Pi Cookbook Pdf
So many books, so little time. Frank Zappa

[PDF]The Whole30 Cookbook
When you do things from your soul, you feel a river moving in you, a joy. Rumi

[PDF] The Ketogenic Cookbook
Open your mouth only if what you are going to say is more beautiful than the silience. BUDDHA

PDF Download Chinese Cookbook
You're not going to master the rest of your life in one day. Just relax. Master the day. Than just keep

PDF Paleo Cookbook
Those who bring sunshine to the lives of others cannot keep it from themselves. J. M. Barrie

Kali Linux Cookbook Pdf
At the end of your life, you will never regret not having passed one more test, not winning one more

PDF Raspberry Pi Cookbook
Love only grows by sharing. You can only have more for yourself by giving it away to others. Brian

[PDF] Electronics Cookbook
Learn to light a candle in the darkest moments of someone’s life. Be the light that helps others see; i

PDF The Whole30 Cookbook
Nothing in nature is unbeautiful. Alfred, Lord Tennyson

Idea Transcript


CakePHP follows the MVC (https://en.wikipedia.org/wiki/Modelview-controller) software design pattern. Programming using MVC separates your application into three main parts: 1. The Model represents the application data 2. The View renders a presentation of model data 3. The Controller handles and routes requests made by the client

A Basic MVC Request Figure: 1 shows an example of a bare-bones MVC request in CakePHP. To illustrate, assume a client named “Ricardo” just clicked on the “Buy A Custom Cake Now!” link on your application’s home page. Ricardo clicks the link pointing to http://www.example.com/cakes/buy (http://www.example.com/cakes/buy), and his browser makes a request to your web server. The dispatcher checks the request URL (/cakes/buy), and hands the request to the correct controller. The controller performs application specific logic. For example, it may check to see if Ricardo has logged in. The controller also uses models to gain access to the application’s data. Models usually represent database tables, but they could also represent LDAP (https://en.wikipedia.org/wiki/Ldap) entries, RSS (https://en.wikipedia.org/wiki/Rss) feeds, or files on the system. In this example, the controller uses a model to fetch Ricardo’s last purchases from the database. Once the controller has worked its magic on the data, it hands it to a view. The view takes this data and gets it ready for presentation to the client. Views in CakePHP are usually in HTML format, but a view could just as easily be a PDF, XML document, or JSON object depending on your needs. Once the view has used the data from the controller to build a fully rendered view, the content of that view is returned to Ricardo’s browser. Almost every request to your application will follow this basic pattern. We’ll add some details later on which are specific to CakePHP, so keep this in mind as we proceed.

Why use MVC? Because it is a tried and true software design pattern that turns an application into a maintainable, modular, rapidly developed package. Crafting application tasks into separate models, views, and controllers makes your application very light on its feet. New features are easily added, and new faces on old features are a snap. The modular and separate design also allows developers and designers to work simultaneously, including the ability to rapidly prototype (https://en.wikipedia.org/wiki/Software_prototyping). Separation also allows developers to make changes in one part of the application without affecting others. If you’ve never built an application this way, it takes some time getting used to, but we’re confident that once you’ve built your first application using CakePHP, you won’t want to do it any other way.

Like 8.4K

Star 7,545

Fork 3,326

Follow

Smile Life

When life gives you a hundred reasons to cry, show life that you have a thousand reasons to smile

Get in touch

© Copyright 2015 - 2024 PDFFOX.COM - All rights reserved.