Professional CodeIgniter® Thomas Myer Wiley Publishing, Inc. ffffiirrss..iinndddd iiiiii 66//1100//0088 55::3399::1177 PPMM ffffiirrss..iinndddd iiii 66//1100//0088 55::3399::1177 PPMM Professional CodeIgniter® Introduction ................................................................................................. xv Chapter 1: Welcome to the MVC World .......................................................... 1 Chapter 2: Agile Methodologies and Approaches .......................................... 23 Chapter 3: A 10,000-Foot View of CodeIgniter .............................................. 45 Chapter 4: Creating the Main Web Site ........................................................ 77 Chapter 5: Building a Shopping Cart .......................................................... 107 Chapter 6: Creating a Dashboard ............................................................... 145 Chapter 7: Improving the Dashboard .......................................................... 189 Chapter 8: Last-Minute Upgrades ............................................................... 235 Chapter 9: Security and Performance ......................................................... 267 Chapter 10: Launch ................................................................................... 295 Index ........................................................................................................ 307 ffffiirrss..iinndddd ii 66//1100//0088 55::3399::1177 PPMM ffffiirrss..iinndddd iiii 66//1100//0088 55::3399::1177 PPMM Professional CodeIgniter® Thomas Myer Wiley Publishing, Inc. ffffiirrss..iinndddd iiiiii 66//1100//0088 55::3399::1177 PPMM Professional CodeIgniter® Published by Wiley Publishing, Inc. 10475 Crosspoint Boulevard Indianapolis, IN 46256 www.wiley.com Copyright © 2008 by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada ISBN: 978-0-470-28245-8 Manufactured in the United States of America 10 9 8 7 6 5 4 3 2 1 Library of Congress Cataloging-in-Publication Data is available from the publisher. No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Legal Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4355, or online at www.wiley.com/go/permissions. Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including without limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or promotional materials. The advice and strategies contained herein may not be suitable for every situation. This work is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional services. If professional assistance is required, the services of a competent professional person should be sought. Neither the publisher nor the author shall be liable for damages arising herefrom. The fact that an organization or Website is referred to in this work as a citation and/or a potential source of further information does not mean that the author or the publisher endorses the information the organization or Website may provide or recommendations it may make. Further, readers should be aware that Internet Websites listed in this work may have changed or disappeared between when this work was written and when it is read. For general information on our other products and services, please contact our Customer Care Department within the United States at (800) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002. Library of Congress Cataloging-in-Publication Data Myer, Thomas. Professional CodeIgniter/Thomas Myer. p. cm. Includes index. ISBN 978-0-470-28245-8 (pbk. : web) 1. Web site development. 2. CodeIgniter (Computer file) 3. Application software—Development. 4. Internet programming. I. Title. TK5105.888.M95 2008 006.7'8—dc22 2008024002 Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Wrox Programmer to Programmer, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other countries, and may not be used without written permission. CodeIgniter is a registered trademark of EllisLab, Inc. All other trademarks are the property of their respective owners. Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book. Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books. ffffiirrss..iinndddd iivv 66//1100//0088 55::3399::1188 PPMM About the Author Thomas Myer currently resides in Austin, Texas, where he runs Triple Dog Dare Media, a consulting group that builds CodeIgniter applications, writes technical documentation and copy, and helps companies and business owners fashion successful strategies for the online world. He is the author of Lead Generation on the Web and No Nonsense XML Web Development with PHP, as well as dozens of articles on technology and business. If you have any feedback on this book or wish to discuss anything related to web development, writing, or marketing, contact him via his web site at www.tripledogs.com. To Hope, for loving me anyway ffffiirrss..iinndddd vv 66//1100//0088 55::3399::1188 PPMM Credits Acquisitions Editor Production Manager Jenny Watson Tim Tate Development Editor Vice President and Executive Group Publisher Kelly Talbot Richard Swadley Technical Editor Vice President and Executive Publisher Ed Finkler Joseph B. Wikert Production Editor Project Coordinator, Cover Debra Banninger Lynsey Stanford Kathleen Wisor Proofreader Copy Editor Nancy Carrasco Cate Caffrey Indexer Editorial Manager Melanie Belkin Mary Beth Wakefield ffffiirrss..iinndddd vvii 66//1100//0088 55::3399::1188 PPMM Acknowledgments My first tip o’ the hat goes to my editor, Kelly Talbot of Wiley, who received all my raving, meandering prose and actually carved a book out of it. Although I kvetched a bit, he was a calm and steady hand navigating this project to a successful completion. (Yes, it’s true, I did call him a slave driver in the heat of the moment. Yes, he is one of the most organized editors I’ve ever had the pleasure to work with. Other authors, take note. The editor is always right.) The second acknowledgment goes to Ed Finkler, who pored over every line of code and made incredibly insightful remarks throughout. Despite the fact that he received the manuscript at quite an advanced stage, he bravely ordered a whole series of changes in order to bring my game up. He followed this up with a tenacious immunity to my whining and crying, and then nodded and patted my head when I finally came around to his point of view. Any technical difficulties you may have with the code are totally his fault. (Just kidding! Seriously, he’s forgotten more than I’ll ever know about software, and without him, this book would have been quite different.) Neil Salkind, my agent, is a pearl beyond price. He’s the kind of guy who will quietly listen to your half-baked ideas and help you shape them into a real pitch that will actually get a publisher’s attention. Without him, I’d just be another guy with dreams of authorship and nothing to his credit. With any book, there are dozens of folks who toil behind the scenes, and it’s impossible to name them all, but I’d like to try. Jenny Watson, who acquired the idea for Wiley, thanks so much for listening to my pitch. Your guidance and feedback in the early stages were very appreciated. Thanks, Debra and Cate, who took over during production edits — What can I say? Cate, I dub thee “World’s Most Efficient Copyeditor” (although I’m sure you will make Copyeditor into two words, which will be funny as all get out — sorry, a little editor humor there). Debra — thanks for taking my calls out of the blue and for helping me put the last little touches on this puppy. Your solid Jersey wisdom on “data are” versus “data is” was much appreciated and a source of much mirth. Thank you, good folks at EllisLab, for creating CodeIgniter — you don’t know how much this framework has changed my relationship with web development and with my clients. In particular, thanks to Derek Allard for responding to my first tentative e-mails and giving me feedback. Thank you, thank you, thank you! To my clients, who accommodated me as I pursued this book, even though you had pressing deadlines and requests of your own: You’re simply the best, and I’m damn lucky to be working with you. Lastly, I extend my thanks to my divine spouse, Hope, who endured many weekends of solitude while I wrote in my little study. And no, I can’t forget the contributions made by Marlowe (our little Yorkie) and Kafka (our lovable mutt), who spent many a slow afternoon sleeping by my feet as I tapped away at the keyboard. ffffiirrss..iinndddd vviiii 66//1100//0088 55::3399::1188 PPMM
Description: