CYAN YELLOW MAGENTA BLACK PANTONE 123 C BOOKS FOR PROFESSIONALS BY PROFESSIONALS® THE EXPERT’S VOICE® IN WEB DEVELOPMENT Companion eBook Available Practical Web 2.0 Applications with PHP Dear Reader, Practical Many programming books on the market today focus specifically on a particu- 2.0 Web lar methodology or software package, and although you will gain a solid under- standing of the subject matter from these books, you won’t always know how to apply what you’ve learned in a real-world situation. This book is designed to show you how to bring together many different ideas and features by start- Practical ing with a clean slate and gradually building the code base so it evolves into a complete web application. The premise of the application we build in this book is that it is a “Web 2.0” application. What this means is that (among other things) our application gen- erates accessible and standards-compliant code while making heavy of use of Ajax. We achieve this by using the Smarty™ Template Engine and Cascading Style Sheets, as well as the Prototype JavaScript library. Additionally, we create a fun and intuitive interface by applying simple visual effects on various pages using the Script.aculo.us JavaScript library. Web 2.0 To help with the development of the extensive PHP code in this book, we Applications with use the Zend Framework. This is an open source PHP 5 library that contains many different components that you can easily use in any of your day-to-day development. We use many of the Zend Framework components in this book, such Applications with as database abstraction (with a focus on MySQL® and PostgreSQL), logging, PHP authentication, and search. The “Web 2.0” application that we build in this book is a collaborative blogging tool. It will allow users to register and create a personal blog. When creating blog posts, users will be able upload images, apply tags, and assign locations (using Google Maps). We will also look at how to use microformats when displaying user blog posts. Quentin Zervaas Develop a complete PHP web application from start to finish Companion eBook RELATED TITLES PHP See last page for details on $10 eBook version SOURCE CODE ONLINE ISBN-13: 978-1-59059-906-8 www.apress.com ISBN-10: 1-59059-906-3 Quentin Zervaas 5 4 4 9 9 US $44.99 Zervaas Shelve in PHP User level: 9 781590 599068 Intermediate–Advanced this print for content only—size & color not accurate spine = 1.1163" 592 page count 9063CH00CMP3 11/19/07 8:39 PM Page i Practical Web 2.0 Applications with PHP Quentin Zervaas 9063CH00CMP3 11/19/07 8:39 PM Page ii Practical Web 2.0 Applications with PHP Copyright © 2008 by Quentin Zervaas All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN-13 (pbk): 978-1-59059-906-8 ISBN-10 (pbk): 1-59059-906-3 ISBN-13 (electronic): 978-1-4302-0474-9 ISBN-10 (electronic): 1-4302-0474-5 Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. Lead Editor: Ben Renow-Clarke Technical Reviewer: Jeff Sambells Editorial Board: Steve Anglin, Ewan Buckingham, Tony Campbell, Gary Cornell, Jonathan Gennick, Jason Gilmore, Kevin Goff, Jonathan Hassell, Matthew Moodie, Joseph Ottinger, Jeffrey Pepper, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh Project Manager: Richard Dal Porto Copy Editors: Andy Carroll, Kim Wimpsett Assistant Production Director: Kari Brooks-Copony Production Editor: Liz Berry Compositor: Diana Van Winkle Proofreader: Lisa Hamilton Indexer: Broccoli Information Management Artist: Diana Van Winkle Cover Designer: Kurt Krames Manufacturing Director: Tom Debolski Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail [email protected], or visit http://www.springeronline.com. For information on translations, please contact Apress directly at 2855 Telegraph Avenue, Suite 600, Berkeley, CA 94705. Phone 510-549-5930, fax 510-549-5939, e-mail [email protected], or visit http://www.apress.com. The information in this book is distributed on an “as is” basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. The source code for this book is available to readers at http://www.apress.com. 9063CH00CMP3 11/19/07 8:39 PM Page iii Contents at a Glance About the Author . xv About the Technical Reviewer . xvi Introduction . xvii ■CHAPTER 1 Application Planning and Design . 1 ■CHAPTER 2 Setting Up the Application Framework . 9 ■CHAPTER 3 User Authentication, Authorization, and Management . 45 ■CHAPTER 4 User Registration, Login, and Logout . 73 ■CHAPTER 5 Introduction to Prototype and Scriptaculous . 123 ■CHAPTER 6 Styling the Web Application . 171 ■CHAPTER 7 Building the Blogging System . 219 ■CHAPTER 8 Extending the Blog Manager . 265 ■CHAPTER 9 Personalized User Areas . 297 ■CHAPTER 10 Implementing Web 2.0 Features . 335 ■CHAPTER 11 A Dynamic Image Gallery . 371 ■CHAPTER 12 Implementing Site Search . 427 ■CHAPTER 13 Integrating Google Maps . 469 ■CHAPTER 14 Deployment and Maintenance . 519 ■INDEX . 547 iii 9063CH00CMP3 11/19/07 8:39 PM Page iv 9063CH00CMP3 11/19/07 8:39 PM Page v Contents About the Author . xv About the Technical Reviewer . xvi Introduction . xvii ■CHAPTER 1 Application Planning and Design . 1 What Is Web 2.0? . 2 Database Connectivity . 2 Web Site Templates . 3 Web Site Features . 3 Main Home Page and User Home Page . 3 User Registration . 4 Account Login and Management . 4 User Blogs . 4 Web Site Search . 4 Application Management . 5 Other Aspects of Development . 5 Search-Engine Optimization . 5 PHPDoc-Style Commenting . 5 Security . 7 Application Logging . 7 Maintainability and Extensibility . 7 Version Control and Unit Testing . 8 Summary . 8 ■CHAPTER 2 Setting Up the Application Framework . 9 Web Server Setup . 9 Operating System . 10 Installing the Apache HTTP Server . 10 Installing MySQL 5 . 11 Installing PHP 5.2.3 . 11 v 9063CH00CMP3 11/19/07 8:39 PM Page vi vi ■CONTENTS Application Filesystem Structure . 12 Web Root Directory . 12 Data Storage Directory . 12 PHP Classes Directory . 13 Templates Directory . 13 Full Directory Structure . 13 Installing the Zend Framework . 14 Configuring the Web Server . 15 Creating a Virtual Host in Linux . 15 Creating a Virtual Host in Windows . 17 Restarting Your Web Server . 17 Setting Up the Database . 17 Using the Model-View-Controller Pattern . 18 Separating Application Logic from Presentation Logic . 19 Directing All Requests to index.php . 21 Introduction to the Zend_Controller Class . 22 How Requests Work with Zend_Controller . 23 Creating the IndexController . 25 Defining Application Settings . 27 Connecting to the Database . ..
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages592 Page
-
File Size-