2. What is a Web
Framework?
• “...software framework that is designed to
support the development of dynamic
websites, Web applications and Web
services.”
- Wikipedia
3. What is a Web
Framework?
• A set of tools and a way to organize them
• NOT an application
• An abstract base from which to build
• NOT a CMS
4. What is a Web
Framework?
• Provide libraries for common tasks
• Provide structure and convention for your
application code
• Promote best practices in application
design/architecture
6. Why Use a Framework?
• Lets you focus on what’s important
• The hard problems have already been
solved by people smarter than you
• Benefits of community
• You (and your requirements) are not
special
• Chances are, you already do
7. Why Cake?
• For a lot of people and a lot of reasons,
Rails = FAIL
• Difficult and expensive to deploy
• Ahem! scaling...
• Programmer availability
• PHP is still by far the #1 web language
8. Why Cake?
• “Oh Rasmus, why do you engage in this
‘virtual crap-flinging’? Can’t you lead by
example like David Heinemeier Hansson?
That guy is the height of maturity and an
expert scalability guy.”
“...look at the top 100 websites on the
internet: about 40% of them are written in
PHP and 0% of them are written in Rails.”
- Terry Chay
9. Why Cake?
• Other PHP frameworks
• Zend Framework
• Symfony
• PHP on Trax
• CodeIgniter
10. An MVC Quickie
Dispatcher The Dispatcher requests the
appropriate Controller/action,
which interacts with the
Model
Controller Model
The Controller then sends the
results of its operations to the
View
view, where it is rendered
11. An MVC Quickie
• Primary: separation between Controller
and View, to partition business logic and
presentation
• Secondary: separation between data
(Model) and Controller
12. An MVC Quickie
A simple example
/* models/post.php */
class Post extends AppModel { }
/* controllers/posts_controller.php */
class PostsController extends AppController {
function index() {
// Get the data from the Model
$posts = $this->paginate();
// Send the data to the view
$this->set(compact(‘posts’));
}
}