Pro zend framework techniques

266 403 3
Pro zend framework techniques

Đ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

Zend Framework Techniques Companion eBook Available Pro Lyman this print for content only—size & color not accurate   CYAN   MAGENTA   YELLOW   BLACK )3".        BOOKs fOr prOfEssiONALs BY prOfEssiONALs ® Pro Zend Framework Techniques: Build a Full CMS Project Dear Reader, Zend Framework is a powerful platform for rapidly creating PHP applications. This book takes you step-by-step through the process of building a simple content management system with Zend Framework and MySQL. You start by installing Zend Server and the framework. Then you learn to leverage the framework’s components, which manage the system’s design, content, users, and navigation, among many other things. With the base system up and run- ning, you move on to advanced topics such as performance tuning and creating an API for your CMS. Each topic adds to your CMS, building a flexible, stable, and powerful platform on which you can base your real-world projects This book is born from my experience of developing sites using many of the current open source CMS systems. These were adequate for the sort of projects that the CMS developers originally had in mind. Working with cre- ative people, though, I found that even the simplest projects inevitably need some customization. Developing pure custom systems is an obvious solution, but it has a down- side. There are many moving parts in a secure web publishing system, and developing them all from scratch takes far too long, as well as distracting you from writing key business logic. Zend Framework gives you the best of both worlds, letting you build exactly the software you want without ever having to reinvent the wheel. Forrest Lyman THE APRESS ROADMAP Pro Zend Framework CMS Beginning Zend Framework Beginning PHP and MySQL US $46.99 Shelve in Programming / PHP User level: Intermediate–Advanced www.apress.com SOURCE CODE ONLINE Companion eBook See last page for details on $10 eBook version )3".        trim = 7.5" x 9.25" spine = 0.59375" 264 page count Pro Zend Framework Techniques Build a Full CMS Project Forrest Lyman Preface by Wil Sinclair Project Lead, Zend Framework Guides you through the entire process of building a customized Content Management System using the many different aspects that Zend Framework offers ThE ExpErT’s VOiCE ®  iN php  The Zend Press Series This book was purchased by angelarce@aarce.com i Pro Zend Framework Techniques Build a Full CMS Project ■ ■ ■ Forrest Lyman The Zend Press Series ii Pro Zend Framework Techniques: Build a Full CMS Project Copyright © 2009 by Forrest Lyman 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-4302-1879-1 ISBN-13 (electronic): 978-1-4302-1880-7 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: Tom Welsh Technical Reviewer: Adam DeFields Editorial Board: Clay Andres, Steve Anglin, Mark Beckner, Ewan Buckingham, Tony Campbell, Gary Cornell, Jonathan Gennick, Michelle Lowman, Matthew Moodie, Jeffrey Pepper, Frank Pohlmann, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh Project Managers: Beth Christmas and Debra Kelly Copy Editor: Kim Wimpsett Compositor: v-prompt e-Services Indexer: BIM Indexing & Proofreading Services Artist: April Milne 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 e-mail info@apress.com, or visit http://www.apress.com. Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales–eBook Licensing web page at http://www.apress.com/info/bulksales. 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. iii I would like to dedicate this book to Johnny, who first introduced me to the magic that can lie within the covers of a book. iv Contents at a Glance ■Foreword viii ■About the Authors ix ■Acknowledgments x ■Introduction xi ■Chapter 1: Getting Started 1 ■Chapter 2: Designing Your Site 17 ■Chapter 3: Building and Processing Web Forms with Zend_Form 37 ■Chapter 4: Managing Data with Zend Framework 53 ■Chapter 5: Working with CMS Data 77 ■Chapter 6: Managing Content 95 ■Chapter 7: Creating the Site Navigation 113 ■Chapter 8: Handling Security in a Zend Framework Project 145 ■Chapter 9: Searching and Sharing Content 171 ■Chapter 10: Extending Your CMS 189 ■Chapter 11: Advanced Topics 203 ■Chapter 12: Installing and Managing a Site with Your CMS 221 ■Index 231 v Contents ■Foreword xvii ■About the Authors xviii ■Acknowledgments xix ■Introduction xx ■Chapter 1: Getting Started 1 Introducing Zend Framework MVC Implementation 1 The Controller: Zend_Controller_Front 2 The Model: Zend_Db 2 The View: Zend_View 3 Setting Up Your Development Environment 3 Installing Zend Server CE 3 Doing Rapid Application Development with the Zend Command-Line Tool 5 Creating Your Project 6 Building a Project with the Zend Tool Framework 6 Testing Your New Project 7 Exploring the Anatomy of Your Project 8 The public Folder 9 Redirecting the Request with .htaccess 9 The Index File 9 Additional Public Folders 10 The library Folder 10 The application Folder 10 Zend_Application 10 The Bootstrap Class 11 Application Configuration 11 Action Controllers 12 Views 12 Error Handling 13 Summary 16 ■ CONTENTS vi ■Chapter 2: Designing Your Site 17 Rendering the Presentation Layer with Zend_View 17 View Scripts 17 View Helpers 17 Rendering the Presentation Layer with Zend_Layout 18 Using Zend_Layout on Its Own 18 Zend_Layout MVC 18 Three-Step Views 18 Designing the Interface 19 Organizing the Interface Components 19 Mocking It Up 21 Creating the Base HTML Page 22 Testing Your Design 25 Creating the Layout 26 Creating the Layout 26 Adding the Dynamic Head with Zend_View’s Placeholders 27 Adding the Dynamic Content to Your Layout 28 Rendering the Controller Response with Zend_Layout 28 Configuring Your Application to Use the Layout 29 Testing Your New Layout 29 Implementing the Skin 30 What Goes in a Skin? 30 Creating the Blues Skin 31 The skin.xml File 31 The Style Sheets 31 Building a View Helper to Render the Skin 33 Using the loadSkin Helper 34 Testing the Skin 35 Summary 36 ■Chapter 3: Building and Processing Web Forms with Zend_Form 37 The Anatomy of a Zend Framework Form 37 Rendering Forms 38 Processing a Form 38 Form Elements 38 Initial Elements 38 Zend_Form_Element_Button 38 Zend_Form_Element_Captcha 39 ■ CONTENTS vii Zend_Form_Element_Checkbox 39 Zend_Form_Element_File 39 Zend_Form_Element_Hidden 39 Zend_Form_Element_Hash 39 Zend_Form_Element_Image 39 Zend_Form_Element_MultiCheckbox 39 Zend_Form_Element_Multiselect 39 Zend_Form_Element_Password 39 Zend_Form_Element_Radio 40 Zend_Form_Element_Reset 40 Zend_Form_Element_Select 40 Zend_Form_Element_Submit 40 Zend_Form_Element_Text 40 Zend_Form_Element_Textarea 40 Custom Form Elements 40 Creating a Page Form 40 Getting Started 41 Creating the Form 41 Adding Controls to the Form 42 The Author Text Control 43 The E-mail Text Control 43 The Date Text Control 44 The URL Text Control 44 The Description Text Area Control 44 The Priority Select Control 45 The Status Select Control 45 The Submit Button 46 Rendering the Form 46 Processing the Form 48 Styling the Form 49 Summary 52 ■Chapter 4: Managing Data with Zend Framework 53 Setting Up the Database 53 Creating the CMS Database 53 Configuring the Database Connection 53 Creating the bugs Table 54 Exploring the Zend Framework Models 55 ■ CONTENTS viii Learning About the Models 56 Creating the Bug Model 57 Working with Bugs 57 Submitting a New Bug 57 Creating the createBug() Method 57 Updating the Bug Controller’s Submit Action 58 Viewing All the Current Bugs 59 Creating the fetchBugs() Method 59 Adding the List Action to the Bug Controller 60 Creating the List View 60 Filtering and Sorting the Bug Reports 62 Updating the fetchBugs() Method 63 Creating the Form to Filter and Sort the Bugs 63 Loading and Rendering the Filter Form 64 Processing the Filters and Sort Criteria 65 Limiting and Paginating Bug Reports Using Zend_Paginator 66 Updating the fetchBugs() Method to Return a Zend_Paginator Adapter 66 Refactoring the Bug Controller listAction() to Load the Paginator 67 Rendering the Bug Reports Using the Paginator 68 Updating a Bug 71 Updating the Bug Report Form 71 Creating the Edit Action 71 Creating the Edit View 72 Updating the Bug Record 72 Deleting a Bug 73 Adding the Delete Method to the Bug Model 74 Creating the Bug Controller Delete Action 74 Summary 75 ■Chapter 5: Working with CMS Data 77 Exploring the Data Structure 77 Traditional CMS Data Structures 77 Abstract Data Structures 77 Designing a Database That Can Grow with Your System 78 Implementing the Data Management System 79 Managing Content Nodes 80 Creating the content_nodes Table 80 Creating the ContentNode Model Class 80 [...]... CommandLine Tool The Zend command-line tool gives developers access to the Zend Tool Framework through the command-line interface Zend Tool Project provides a number of tools for creating new projects and adding components to existing projects Zend Tool Project is configured as part of the Zend Server installation, but it is not difficult to manually configure it if you are not using Zend Server Consult... around unrelated code Introducing Zend Framework MVC Implementation Zend Framework s MVC implementation consists of three main components: • Zend_ Controller • The model, which often consists of a Zend_ Db_Table class but can be any data source • Zend_ View At its simplest, Zend_ Controller processes the request, fetches data from Zend_ Db, and then passes this data to Zend_ View to render the dynamic XHTML... /> Helpful Links: Zend Framework Website | Zend Framework Manual Error Handling It is probably safe to assume that everything worked fine in this simplistic example, but errors are a fact of life in programming Zend Framework includes an error plug-in that handles these issues... will be ~/Apache2/htdocs You create a new project using the create project command Follow this command with the name of your project, which in this case will be zf_cms Run this command, and the Zend Tool Framework will build the base project, as in Figure 1-3 Figure 1-3 Creating a project with the Zend Tool Framework 6 CHAPTER 1 ■ GETTING STARTED Testing Your New Project Now if you point your browser to... found on http:/ /framework .zend. com Wil Sinclair Project Lead, Zend Framework xiv About the Author ■ Forrest Lyman is a passionate open source developer who splits most of his time between developing dynamic web sites powered by Zend Framework and building systems to make it easier for other people to do the same He is the creator of the Digitalus CMS open source project, which is a Zend Framework based... install the library in each project This is because you may run several ZF projects on a single server, and different projects may be built on different versions of the framework Download the most recent version of the framework at http:/ /framework .zend. com Extract the archive contents, and then copy the Zend folder from the download’s library folder into your library folder The framework is simply a library... Figure 1-4 Zend Framework project welcome screen Exploring the Anatomy of Your Project If you open the folder that the Zend Tool Framework created for your project, you will see that the project is organized into three subfolders: • public: All the files that must be publicly accessible will reside in this folder, which will be your document root • library: This folder will contain the framework s... url(http:/ /framework .zend. com/images/bkg_body-bottom.gif); height: 100%; } Welcome to the Zend Framework! This is your project's main page Helpful Links: Zend. .. Consult the documentation for Zend Framework for more information on this subject Next open a terminal window Next check the current version of the framework using the zf show version command If everything is properly set up, you should see Zend Framework Version: 1.8.x, as in Figure 1-2 Figure 1-2 Running the zf show version command 5 CHAPTER 1 ■ GETTING STARTED The Zend Tool Framework uses one of two... Strategist at Zend Technologies He brings 10 years of experience in the software industry at companies from the smallest startups to the largest multinationals such as Oracle and Amazon Most recently he served as project lead on the leading PHP framework: Zend Framework xvi Acknowledgments I would like to take a moment to thank everyone who helped make this book possible When I first proposed the project,

Ngày đăng: 23/06/2014, 13:05

Từ khóa liên quan

Mục lục

  • Lyman 1879-1 FSB.pdf

  • 18791_000.pdf

    • 18791_FM_1-v.pdf

    • 18791_FM_vi-xiii.pdf

    • 18791_FM_xiv-xviii.pdf

    • 18791_001.pdf

    • 18791_002.pdf

    • 18791_003.pdf

    • 18791_004.pdf

    • 18791_005.pdf

    • 18791_006.pdf

    • 18791_007.pdf

    • 18791_008.pdf

    • 18791_009.pdf

    • 18791_010.pdf

    • 18791_011.pdf

    • 18791_012.pdf

    • 18791_Index.pdf

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

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

Tài liệu liên quan