Wiley 978-0-470-28245-8 Datasheet

Browse online or download Datasheet for Software manuals Wiley 978-0-470-28245-8. Wiley Professional CodeIgniter User Manual

  • Download
  • Add to my manuals
  • Print
  • Page
    / 22
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 0
Welcome to the MVC World
This book is about CodeIgniter and the world of Model - View - Controller (MVC) web development.
Before venturing into the topic of CodeIgniter, it s helpful to put it into some kind of context.
However, most programmers who are new to the world of MVC web development find some of
the concepts hard to grasp at first they ve been so engrained in the old way of doing things that
unlearning is difficult at first.
So even before you can learn anything about CodeIgniter or even MVC, it s probably helpful to
start the discussion with something you already know and understand, and then move on from
there. Therefore, that s where this book begins: with a description of a prototypical PHP project,
most likely very similar to anyone s very first PHP project.
Many PHP programmers learn PHP either as their first language (having only been exposed to
XHTML and CSS beforehand) or after learning another similar language (such as Perl). Most of the
time, a PHP programmer s first few projects involve a pretty steep learning curve, but eventually
the programmer finds a comfortable groove. He ends up with a project consisting of the following
components:
A series of PHP pages with intermingled PHP commands, SQL queries, and XHTML
A series of JavaScript and CSS files that are linked from those PHP pages
A series of universal includes a footer file for all pages and a header file that contain the
database connection and session initialization code
A handful of database tables that store the application ’ s data
c01.indd 1c01.indd 1 6/10/08 5:29:55 PM6/10/08 5:29:55 PM
COPYRIGHTED MATERIAL
Page view 0
1 2 3 4 5 6 ... 21 22

Summary of Contents

Page 1 - COPYRIGHTED MATERIAL

Welcome to the MVC World This book is about CodeIgniter and the world of Model - View - Controller (MVC)

Page 2

Chapter 1: Welcome to the MVC World 10 Comparing PHP MVC Frameworks When you look at CodeIgniter, Symfony, and CakePHP, you ’ ll notice

Page 3

Chapter 1: Welcome to the MVC World 11 Figure 1 - 4 illustrates a typical CakePHP model. Figure 1-4 Symfony ’ s approach allows you to us

Page 4

Chapter 1: Welcome to the MVC World 12 Strictly speaking, CodeIgniter doesn ’ t require models at all. Although this may seem a bit confusing at

Page 5

Chapter 1: Welcome to the MVC World 13 In the following sections, you see how you ’ d go about doing that. The examples provided in the next few

Page 6 - Why Bother with MVC ?

Chapter 1: Welcome to the MVC World 14 The fetchHomePage() function is very simple, but it pays huge dividends to understand what is going on

Page 7 - A Brief History of MVC

Chapter 1: Welcome to the MVC World 15 As before, this controller is bare - bones, consisting of just an initialization function that ties this

Page 8

Chapter 1: Welcome to the MVC World 16 } function index(){ $this- > load- > model(‘Page_model’,’’,TRUE); $data[‘conte

Page 9

Chapter 1: Welcome to the MVC World 17 Notice the use of the $content array whenever you access what you need. You may be wondering about that

Page 10 - Models

Chapter 1: Welcome to the MVC World 18displaysdata forloads index()runs fetchHomePage()loadsloadsusercontrollerviewmodelFigure 1-5 A Slightly D

Page 11

Chapter 1: Welcome to the MVC World 19Using Third-Party Templating SystemsMost of the time, you’ll want to use PHP templates with CodeIgniter, a

Page 12 - Helpers and Libraries

Chapter 1: Welcome to the MVC World 2 In fact, a newbie programmer ’ s first PHP page probably looks a lot like this one: < ?phpinclude_once

Page 13

Chapter 1: Welcome to the MVC World 20 Note the two additions to the index() method: loading the parser library and then calling the parser, p

Page 14 - Creating the Controller

Chapter 1: Welcome to the MVC World 21 < ?phpclass Page_model extends Model{ function Page_model(){ parent::Model(); }

Page 15

Chapter 1: Welcome to the MVC World 22 Next, use the auto_typography() function in the view: < html > < head > < title

Page 16 - Creating the View

Chapter 1: Welcome to the MVC World 3 Six months later, the programmer gets a call from the client, and the problems begin — not big problems

Page 17

Chapter 1: Welcome to the MVC World 4 }else{ $hp[‘title’] = “Welcome to our web site!”; $hp[‘css’] = “default.css”; $hp[‘bodycopy’] =

Page 18

Chapter 1: Welcome to the MVC World 5extend. Furthermore, MVC frameworks are usually pretty structured, allowing the developer to concentrate on

Page 19 - Modifying the Controller

Chapter 1: Welcome to the MVC World 6 Because of MVC ’ s three - part separation, developers can create multiple views and controllers for any

Page 20 - What about {bodycopy} ?

Chapter 1: Welcome to the MVC World 7 If they want to change the number of blog posts that get retrieved (or even the order in which they are d

Page 21

Chapter 1: Welcome to the MVC World 8that knew how to render what you wanted to render. For example, if you wanted to draw a rectangle or a circ

Page 22 - Conclusion

Chapter 1: Welcome to the MVC World 9 The next step in MVC (no pun intended) occurred with the arrival of the NeXT operating system and its soft

Comments to this Manuals

No comments