Chapters
Introduction
Chapter 1
Audience
This book is for PHP developers with a moderate understanding of the PHP language and who are looking for a creative edge when developing web applications.
It's recommended that you touch up on your array skills before diving in to the world of Madeam.
What is Madeam?
Madeam is a PHP Model View Controller (MVC) Framework that allows for rapid application development (RAD) for the new web. It is originally inspired by David Heinemeier Hansson's Ruby On Rails framework. It's main focus is to give developers the creative freedom and tools to realize their dream applications without any frustration.
The name Madeam comes from a hack of the sentence "Made after midnight" or "Made AM". It represents the long hours spent by every programmer working on a project in the middle of the night. Programmers are nocturnal and the name is to honor that culture.
Why use Madeam?
If you're looking to prototype and deploy quality applications quickly, Madeam provides you with the structure and tools to realize any web application you want.
History and Words From The Creator
I started the Madeam framework in the summer of 2006 as a project to see if I could do some of the things the Ruby community was doing with Rails but in PHP. Madeam has always been a "I wonder if I can do this" project and it's become a very important learning experience for me. That's why the development of Madeam has continued even as other PHP MVC frameworks grow.
I think it's important that the PHP community have more than 1 framework. Rails has proved to be very successful in the Ruby community because everyone is committing their time to the same project. However I believe more can be learned from multiple projects and a variety of communities where opinions clash and ideas are looked at in-depth.
-- Joshua Davey
What is MVC?
MVC stands for Model View Controller. MVC is a way of separating your data, logic and presentation code. With MVC, models represent your data in the database, views are your templates and controllers are your logic code. Because Madeam already follows these conventions it makes organizing your application's code painless and easy for everyone working on your team.
(M)odels
A single model represents a group of data. Normally this means it represents a table in the database but it can also represent other things like a directory with a list of files. Models also allow you to state relationships between them which allows for dynamic query generation. (Models chapter)
(V)iews
The view is a template that is rendered for the user to see and is created by a controller's "action". The format of the view can be anything but normally when creating web applications it's HTML. Because the view can represent any sort of data structure (HTML, XML, JSON, etc...) the view can be used for more than just talking to humans. It can also be used for talking to other programs and creating APIs. (Views chapter)
(C)ontrollers
Controllers are a very important part of the MVC stack. All of your "business logic" goes in your controller. It's where you get data from the database, send data to the view, format user input and everything else. The controller is organized into "actions" which are functions within the controller's class. To get your head around the idea of actions you can think of the controllers as directories and actions as the pages within the directories. (Controllers chapter)
Naming Conventions
Almost everything that is created in Madeam follows a naming convention. This is to ensure consistency, readability and reduce the amount of configuration necessary.
Controllers
File: name_controller.php
Class: nameController.php
Models
File: name_model.php
Class: nameModel
Use: $this->Name->method();
Components
File: name_component.php
Class: nameComponent
Use: $this->name->method();
Helpers
File: name_help.php
Class: nameHelp
Use: nameHelp::method();
Views
File: name.ext
Note: ext can be anything. For example: name.html or name.xml
Auto Magic
When you first boot up Madeam you'll notice a lot of things already done for you. For example you don't need to define a layout for your controller because it's done for you by default. Below is a list of the default settings created by Madeam.
- Controller's layout = 'standard'
Next Chapter