Practical Web 2.0 Applications with PHP phần 1 doc

60 427 1
Practical Web 2.0 Applications with PHP phần 1 doc

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

this print for content only—size & color not accurate spine = 1.1163" 592 page count Books for professionals By professionals ® Practical Web 2.0 Applications with PHP Dear Reader, Many programming books on the market today focus specifically on a particu- 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- 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. To help with the development of the extensive PHP code in this book, we 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 as database abstraction (with a focus on MySQL ® and PostgreSQL), logging, 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 US $44.99 Shelve in PHP User level: Intermediate–Advanced Zervaas Web 2.0 Applications with PHP The eXperT’s Voice ® in WeB DeVelopmenT Practical Web 2.0 Applications with PHP cyan maGenTa yelloW Black panTone 123 c Quentin Zervaas Companion eBook Available www.apress.com SOURCE CODE ONLINE Companion eBook See last page for details on $10 eBook version ISBN-13: 978-1-59059-906-8 ISBN-10: 1-59059-906-3 9 781590 599068 5 4 4 9 9 Develop a complete PHP web application from start to finish RELATED TITLES Practical Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com Quentin Zervaas Practical Web 2.0 Applications with PHP 9063CH00CMP3 11/19/07 8:39 PM Page i Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com 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 orders-ny@springer-sbm.com, 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 info@apress.com, 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 ii Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com 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 iii Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com 9063CH00CMP3 11/19/07 8:39 PM Page iv Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com 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 v Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com ■CONTENTSvi 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 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 Testing the Database Connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 The Smarty Template Engine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 Why Not Use a Different Template Engine? . . . . . . . . . . . . . . . . . . . . 33 Downloading and Installing Smarty . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 Automatic View Rendering with Zend_Controller . . . . . . . . . . . . . . . 36 Integrating Smarty with the Web Site Controllers . . . . . . . . . . . . . . . 39 Adding Logging Capabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 Writing to the Log File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 ■CHAPTER 3 User Authentication, Authorization, and Management . . . . . . 45 Creating the User Database Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 Timestamps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 User Profiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 Introduction to Zend_Auth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 Instantiating Zend_Auth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 Authenticating with Zend_Auth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 Introduction to Zend_Acl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 A Zend_Acl Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 9063CH00CMP3 11/19/07 8:39 PM Page vi Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com Combining Zend_Auth, Zend_Acl, and Zend_Controller_Front . . . . . . . . 57 Managing User Records with DatabaseObject . . . . . . . . . . . . . . . . . . . . . . 61 The DatabaseObject_User Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 Using DatabaseObject_User . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 Managing User Profiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 Using Profile_User . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 Integrating Profile_User with DatabaseObject_User . . . . . . . . . . . . 69 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 ■CHAPTER 4 User Registration, Login, and Logout . . . . . . . . . . . . . . . . . . . . . 73 Adding User Registration to the Application . . . . . . . . . . . . . . . . . . . . . . . . 73 Creating the Form Processor for User Registration . . . . . . . . . . . . . 74 Displaying the Registration Form and Processing Registrations . . . 81 Adding CAPTCHA to the User Registration Form . . . . . . . . . . . . . . . . 88 Adding E-mail Functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 Implementing Account Login and Logout . . . . . . . . . . . . . . . . . . . . . . . . . . 100 Creating the Login Template . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 Adding the Account Controller Login Action . . . . . . . . . . . . . . . . . . . 102 Logging Successful and Failed Login Attempts . . . . . . . . . . . . . . . . 105 Logging Users Out of Their Accounts . . . . . . . . . . . . . . . . . . . . . . . . 107 Dealing with Forgotten Passwords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 Resetting a User’s Password . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 Functions for Resetting Passwords . . . . . . . . . . . . . . . . . . . . . . . . . . 112 Implementing Account Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 Creating the Account Home Page . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 Updating the Web Site Navigation . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 Allowing Users to Update Their Details . . . . . . . . . . . . . . . . . . . . . . . 120 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 ■CHAPTER 5 Introduction to Prototype and Scriptaculous . . . . . . . . . . . . 123 Downloading and Installing Prototype . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 Prototype Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 Selecting Objects in the Document Object Model . . . . . . . . . . . . . . . . . . . 124 The $() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 The getElementsByClassName() Function . . . . . . . . . . . . . . . . . . . . 125 The $$() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 The getElementsBySelector() Function . . . . . . . . . . . . . . . . . . . . . . . 129 Prototype’s Hash Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 ■CONTENTS vii vii 9063CH00CMP3 11/19/07 8:39 PM Page vii Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com Other Element Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 Showing and Hiding Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 Retrieving Dimensions of Elements . . . . . . . . . . . . . . . . . . . . . . 131 Managing Classes of Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 Manipulating Strings with Prototype . . . . . . . . . . . . . . . . . . . . . . . . . 133 Ajax Operations in Prototype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134 Ajax Request Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134 Ajax Callback Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 JavaScript Object Notation (JSON) . . . . . . . . . . . . . . . . . . . . . . . . . . 138 An Ajax.Request Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 Event Handling in Prototype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 Observing an Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 Finding Out Which Element an Event Occurred On . . . . . . . . . . . . . 146 Canceling an Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 Creating JavaScript Classes in Prototype . . . . . . . . . . . . . . . . . . . . . . . . . 147 Creating a Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 Binding Function Calls to Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 From Prototype to Scriptaculous . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 Prebuilt Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 Drag and Drop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 Visual Effects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 DOM Element Builder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 JavaScript Unit Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 Downloading and Installing Scriptaculous . . . . . . . . . . . . . . . . . . . . . . . . . 154 Combining Prototype, Scriptaculous, Ajax, and PHP in a Useful Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 Creating the Main HTML Page: index.php . . . . . . . . . . . . . . . . . . . . 156 Styling the Application: styles.css . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 Creating and Populating the Database: schema.sql . . . . . . . . . . . . 158 Managing the List Items on the Server Side: items.php . . . . . . . . 159 Processing Ajax Requests on the Server Side: processor.php . . . 161 Creating the Client-Side Application Logic: scripts.js . . . . . . . . . . . 163 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 ■CHAPTER 6 Styling the Web Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 Adding Page Titles and Breadcrumbs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 The Breadcrumbs Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172 Generating URLs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174 Setting the Title and Trail for Each Controller Action . . . . . . . . . . . . 178 Creating a Smarty Plug-In to Output Breadcrumbs . . . . . . . . . . . . 180 Displaying the Page Title . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 ■CONTENTSviii 9063CH00CMP3 11/19/07 8:39 PM Page viii 809b8b6f91d5ff50033254241f3132ed Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com [...]... fresh version of PHP Note that these commands only include the minimum options required for compatibility with the code in this book # tar -zxf php- 5.2.3.tar.gz # cd php- 5.2.3 # /configure with- apxs2 \ with- gd with- curl \ with- mysql with- pdo-mysql \ with- jpeg-dir with- png-dir \ with- freetype-dir with- zlib # make # make install Once these commands have successfully executed, PHP should be compiled... /usr/local/lib /php 11 9063Ch02CMP4 11 /4/07 12 :23 PM Page 12 Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com 12 CHAPTER 2 ■ SETTING UP THE APPLICATION FRAMEWORK ■ Note Please ensure that your version of PHP is built with the GD library enabled, as we will use it in this book for generating CAPTCHA images (Chapter 4) and for resizing uploaded images (Chapter 11 ) When you run... command, the Apache httpd.conf file will be modified to load the PHP library; however, you may still need to add the following lines to ensure that Apache recognizes files with the extension php as PHP files: AddType application/x-httpd -php php AddType application/x-httpd -php- source phps This second line is optional, but it is included with the PHP documentation, so I have included it here You should also... We will be using many PHP 5-specific features, so you will not be able to run the code in this book on PHP 4 Strictly speaking, you can use a version of PHP 5 earlier than 5.2.3, but it is best to use the latest available version Note that the Zend Framework requires a minimum PHP version of 5 .1. 4 Download PHP 5.2.3 (or later) from the PHP web site (http://www .php. net/downloads .php) , and use the following... CHAPTER 1 ■ APPLICATION PLANNING AND DESIGN What Is Web 2.0? So exactly what defines a web site as being Web 2.0 ? There are many different opinions on this, making it difficult to pinpoint an exact definition; however, some of the features typically associated with Web 2.0 sites are as follows: • Using standards-compliant HTML and CSS This allows sites to work across many platforms and helps with accessibility... commented using PHPDoc-style comments, allowing us to easily build API documentation for all our classes PHPDoc is based on Sun’s Javadoc system, which is a simple method of commenting all functions, arguments, variables, and packages so developers can easily reuse them 5 9063Ch01CMP2 10 /20/07 1: 47 PM Page 6 Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com 6 CHAPTER 1 ■ APPLICATION... followed by a brief description of what the return data contains For more information about phpDocumentor, read the “phpDocumentor Guide to Creating Fantastic Documentation” at http://www.phpdoc.org/tutorial .php Security We will be looking closely at the security of our web site, as this very important aspect of web development is often overlooked or implemented incorrectly For instance, we will focus... of the book’s web site 9063Ch01CMP2 10 /20/07 1: 47 PM Page 1 Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com CHAPTER 1 Application Planning and Design I n this book we will be creating a blogging web application that will allow us to cover not only all of the different PHP and database considerations involved, but also a number of different Web 2.0 principles (such as Ajax and... Class 511 Updating the Blog Post Display Template 514 Summary 516 ■ CHAPTER 14 Deployment and Maintenance 519 Application Logging 519 E-mailing Critical Errors to an Administrator 519 Using Application Logs ... the /** … */ block This is primarily to improve readability and to easily identify entire PHPDoc blocks The final section of the comment block contains the various PHPDoc parameters used by the parser to link the API documentation together better and to provide you with useful documentation Each parameter begins with @, directly followed by the name of the parameter Following that is the information . Zervaas Practical Web 2. 0 Applications with PHP 906 3CH00CMP3 11 /19 /07 8:39 PM Page i Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com Practical Web 2. 0 Applications with PHP Copyright. . 1 80 Displaying the Page Title . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 82 ■CONTENTSviii 906 3CH00CMP3 11 /19 /07 8:39 PM Page viii 809 b8b6f91d5ff 500 3 325 424 1f 313 2ed Simpo. retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN -13 (pbk): 978 -1- 5 905 9- 906 -8 ISBN- 10 (pbk): 1- 5 905 9- 906 -3 ISBN -13 (electronic): 978 -1- 43 02 - 04 74-9 ISBN -10

Ngày đăng: 12/08/2014, 13:21

Từ khóa liên quan

Mục lục

  • Practical Web 2.0 Applications with PHP

    • Contents at a Glance

    • Contents

    • About the Author

    • About the Technical Reviewer

    • Introduction

      • Who This Book Is For

      • How This Book Is Structured

      • Prerequisites

      • Downloading the Code

      • Contacting the Author

      • Application Planning and Design

        • What Is Web 2.0?

        • Database Connectivity

        • Web Site Templates

        • Web Site Features

          • Main Home Page and User Home Page

          • User Registration

          • Account Login and Management

          • User Blogs

          • Web Site Search

          • Application Management

          • Other Aspects of Development

            • Search-Engine Optimization

            • PHPDoc-Style Commenting

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan