Professional Documents
Culture Documents
Codeigniterhandbook Vol 1
Codeigniterhandbook Vol 1
"#$% '(#)%*+,
-./ 012/3453-/' .6527118
9+*(#% : ; <=+ 5%%>? '()@A
!"# %&&'( )*+,-
Copyrght 2012 |ame Rumbeow
A rghts reserved. No part of ths book may be reproduced wthout the pror
wrtten permsson of the pubsher, except for persona use and the case of
bref quotatons embedded n artces or revews.
Every effort has been made to ensure the accuracy of the nformaton
presented. However, the nformaton contaned n ths book s sod wthout
warranty, ether express or mped. Nether the authors, Efend Pubshng
nor ts deaers or dstrbutors w be hed abe for any damages caused or
aeged to be caused drecty or ndrecty by ths book.
Efend Pubshng has endeavored to provde trademark nformaton about
a companes and products mentoned n ths book, however we cannot
guarantee that ths nformaton s 100% accurate.
CodeIgnter s a regstered trademark of EsLab, Inc. CodeIgnter ogo
copyrght 2007 - 2012 EsLab, Inc., used wth permsson.
Frst Pubshed: 2012
Ths Edton Pubshed: 2012
Pubshed by Efendi Publishing
ISBN: 978-0-9571791-1-0
For Mum, Dad and the Alexes. l couldn't ask for better people in my life.
./+0& 12 3#45&45(
Acknowedgments.............................................................................
An Introducton to The CodeIgnter Handbook .................................
An Introducton to Voume One........................................................
Who shoud read ths book? .............................................................v
Part 1 - Modes
Fat Mode, Sknny Controer........................................... 3
Standard Mode Conventons.......................................... 4
Observers ..................................................................... 16
Scopng......................................................................... 20
Vadaton ..................................................................... 26
MY_Mode...................................................................... 32
Part 2 - Vews
Presenters .................................................................... 34
Partas.......................................................................... 42
Fragment Cachng ........................................................ 46
Part 3 - Controers
Autooadng Vews ........................................................ 54
Layouts......................................................................... 59
Autooadng Modes ...................................................... 65
Fters............................................................................ 68
Part 4 - REST
HTTP: The Forgotten Protoco ....................................... 73
CodeIgnter-frendy sem-RESTfu Routng................... 77
Summary ....................................................................................... 81
6784#90&':;&45(
A huge thank you to my fantastc edtors, Hope Doty and Dean Howe.
Wthout your treess efforts the book woud probaby be fu to the brm wth
overy-pretentous, bady speed ocutons and horrendousy broken code
sampes. Many thanks go to the ove of my fe-the ever-gorgeous and
wonderfuy taented Laura Parrott-for her fantastc ustratons that provde
a much needed vsua break between the reams of otherwse pateaung
textua boredom. Thanks to Chare + Matt over at Prnt GDS for beng so
understandng and hepng me destroy the panet, one dead tree at a tme.
Cheers to the EsLab team for CodeIgnter and aowng us to use ther
ogo. Thanks to the CodeIgnter Crew: Ph Sturgeon, Eot Haughn, Tom
Myer, |eremy Gmbe, Erskne, Coy, Fve Smpe Steps, A Book Apart, Smon
and Angea Campbe and the EE ot.
Thanks to me Mum and Dad for keepng me suffcenty sober and
adequatey drunk, respectvey. Lots of ove to my Granny who passed away
before ths book coud be pubshed. Love to my frends: Aex, Aex, Izzy,
Cauda and everyone ese, and Chrs, Bea, Pat, the Lambs + Rot, Andy
and |o n Bath for ookng after me.
I woud aso ke to thank you, dear reader, for provdng me wth enough
dsposabe ncome to buy an Aston Martn. Naturay, Im |okng. Nobody
became rch from wrtng a tech book. |ust ask Tom Myer.
But a guy can dream, rght?