Tải bản đầy đủ (.pdf) (27 trang)

Pro Zend Framework Techniques Build a Full CMS Project phần 1 pptx

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (2.93 MB, 27 trang )

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



Download at WoweBook.Com
i
Pro Zend Framework
Techniques

Build a Full CMS Project








■ ■ ■
Forrest Lyman

The Zend Press Series

Download at WoweBook.Com
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-
, or visit .
For information on translations, please e-mail , or visit
.
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

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 .

Download at WoweBook.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.

Download at WoweBook.Com
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

Download at WoweBook.Com
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
Download at WoweBook.Com
■ 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
Download at WoweBook.Com
■ 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
Download at WoweBook.Com
■ 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
Download at WoweBook.Com
■ CONTENTS
ix
Creating and Updating Content Nodes 81
Deleting Nodes 82
Managing Pages 82
Creating the pages Table 82
Creating the Page Model Class 82
Creating Pages 83
Updating Existing Pages 83
Deleting a Page 84

Defining and Working with Table Relationships 85
Defining the Relationships 85
The ContentNode to Page Relationship 85
The Page to Parent Page Relationship 85
Working with Related Items 86
Cascading Updates and Deletes 87
Working with Content Items 87
Using the Abstract CMS Content_Item Class 87
Creating the Base Class 87
Loading Pages 88
Using Utility Methods 90
Manipulating Data 91
Extending the Base Content Item Class 92
Summary
93
■Chapter 6: Managing Content 95
Creating and Updating Content Pages 95
Creating the Page Content Item Class 95
Creating the Page Controller 97
Creating the Page Form 97
Rendering the Page Form 98
Inserting the New Page 100
Managing Pages 101
Editing an Existing Page 103
Opening a Page to Edit 103
Updating the Page 104
Deleting Pages 105
Rendering Pages 105
The Home Page 105
Rendering the Most Recent Pages 106

Download at WoweBook.Com
■ CONTENTS

x
Setting This Page As Your Site’s Home Page 110
Opening a Page 110
Summary 112
■Chaptrer 7: Creating the Site Navigation 113
How CMSs Manage Menus 113
Managing Menu Data 113
Creating the Menu Controllers 115
Creating a New Menu 116
Creating the Menu Form 116
Rendering the Create Menu Form 117
Processing the Form 119
Listing Current Menus 120
Updating a Menu 123
Opening the Menu to Edit 124
Updating the Menu 124
Deleting Menus 126
Managing Menu Items 126
Listing the Menu Items 127
Adding New Menu Items 129
The Menu Item Form 129
Creating the Add Menu Item Action 130
Rendering the Menu Item Form 131
Processing the Form 131
Sorting Menu Items 132
Updating Menu Items 135
Loading the Update Item Form 135

Rendering the Update Item Form 136
Processing the Update Item Form 136
Deleting Menu Items 137
Rendering Menus 138
Creating the Main Site Menus 139
Creating the Main Menus 139
Setting the Main Menu GUIDs 139
Rendering the Main Menus 140
Rendering the Admin Menu 141
Creating SEO-Friendly URLs 142
Summary 144
Download at WoweBook.Com
■ CONTENTS
xi
■Chaper 8: Handling Security in a Zend Framework Project 145
Managing CMS Users 145
User Data and Model 146
Creating a New User 146
Creating the User Controller 146
Creating the User Form 147
Rendering the Create User Form 148
Processing the Form 149
Managing Existing Users 151
Updating Users 154
Deleting Users 157
Authenticating Users with Zend_Auth 158
Creating the User Landing Page 159
Creating the User Login 159
Logging Users Out 161
Adding User Controls to the Main CMS Interface 162

Controlling Access with Zend_Acl 164
Using Zend_Acl 165
Securing Your CMS Project 165
Summary 169
■Chapter 9: Searching and Sharing Content 171
Working with the Lucene Search Engine 171
Creating a Search Index 171
Documents and Fields 171
Implementing Site Search 172
Securing Site Search 172
Creating the Search Index 173
The Build Action 173
The Build Search View 174
Searching the Site 174
The Search Form 175
Adding the Search Form to the Site 175
Processing a Search Request 176
Rendering Search Results 176
Testing Site Search 177
Working with Zend Feed 177
Creating the What’s New Feed 178
Download at WoweBook.Com
■ CONTENTS

xii
Securing the Feeds 178
Building and Rendering the Feed 178
Adding the Feed to the Site 180
Web Services and Zend Framework 181
Working with Existing Services 181

Creating an API for your CMS with Zend REST 182
The Base Class 182
Securing the API 182
Searching Pages 183
Creating Pages 183
Updating Pages 184
Deleting Pages 185
Creating the API Server 185
Testing the API 186
Testing Searching 186
Testing Creating a Page 187
Updating the Page 187
Deleting the Page 188
Summary 188
■Chapter 10: Extending Your CMS 189
Creating the Module 189
Configuring Your Application to Load Modules 190
Rendering the Contact Form 191
Processing the Contact Form 193
Sending Mail with Zend_Mail 194
Creating the Mail Template 194
Rendering and Sending the HTML Message 195
The Confirmation Message 196
Securing the Form with Captcha 197
Using SMTP Mail Transport 198
File Attachments
199
Uploading the File 199
Attaching the File to Your Message 201
Summary 202

■Chapter 11: Advanced Topics 203
Performance Tuning 203
About Zend_Db_Profiler 203
Download at WoweBook.Com
■ CONTENTS
xiii
Testing Your Application 203
Creating the Profiler View Script 204
Adding the Profiler Script to the Site 205
Optimizing the CMS_Content_Item_Page Class 206
Caching 208
Implementing Cache 208
Configuring the Cache 209
Creating the Cache Application Resource 209
Caching Menu Data 211
Updating the Cached Menus 213
Caching Content Items 215
Internationalization 216
Getting Started with Zend_Translate 216
Zend_Translate_Adapters 216
Integrating Zend_Translate with Your Project 216
Other Hidden Gems 218
Summary 218
■Chapter 12: Installing and Managing a Site with Your CMS 221
Creating the Database 221
Installing the Application 223
Alternate Installations 224
Sharing One Common Library 224
Configuring Your CMS 224
Managing Users 224

Creating a User 225
Updating a User 226
Deleting a User 226
Managing Content 226
Creating a Page 227
Updating a Page 227
Deleting a Page 228
Navigating Between Pages 228
Adding a Menu Item 228
Sorting Menu Items 229
Updating Menu Items 230
Deleting Menu Items 230
The Next Steps 230
■Index 231
Download at WoweBook.Com
xiv
Preface
Zend Framework has been designed from the ground up to make PHP development as easy — and fun —
as possible while promoting best practices and providing an extensible framework for complex
applications. Content management systems are a particularly important class of applications — after all,
serving content is what the web does best. As the project lead of the Digitalus CMS project, a commercial
CMS built on Zend Framework, Forrest Lyman is particularly well-qualified to guide the reader through
the involved process of building a full-fledged CMS.
This book reflects the best practices that we have discovered with the help of the Zend
Framework community over the last four years. Forrest brings our MVC components to life, while
describing data persistence in detail using Zend_Db_Table and MySQL. Essential components for CMSs,
such as Zend_Search_Lucene and Zend_Feed, are used to develop ZF modules to implement practical
use cases. Finally, he covers advanced topics such as performance optimization and designing your CMS
for extension.
Those looking for a guide to using the latest components in Zend Framework will not be

disappointed — Zend_Tool, Zend_Navigation, Zend_Application, and more are put to use in the
extensive running example CMS application.
This book is the perfect complement to the documentation that can be found on
.

Wil Sinclair
Project Lead, Zend Framework

Download at WoweBook.Com
xv
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 content
management system. When he is not in front of a computer, he is usually spending
time with his girls, Luna and Stella, or searching for tuna offshore.
Download at WoweBook.Com
xvi
About the Technical Reviewers

■Adam DeFields is a consultant specializing in web application development,
project management, technical writing/editing, and instructional design. He lives
in Grand Rapids, Michigan, where he runs Emanation Systems, LLC
(www.emanationsystemsllc.com), an IT services company he founded in 2002. He
has coauthored or reviewed more than a dozen books on various technologies,
including Java, PHP, Apache, MySQL, and Zend Framework.









■Wil Sinclair is currently working on technologies that facilitate and encourage
cloud adoption in the PHP community as the Cloud 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.

Download at WoweBook.Com
xvii
Acknowledgments
I would like to take a moment to thank everyone who helped make this book possible. When I first
proposed the project, I had no idea how much work went into writing, editing, and publishing a book. I
don’t believe this project would have been possible without all of the support and encouragement I have
received.
I would like to start by thanking all of the developers who worked on the Zend Framework project and
who guided me through my early days learning new ways to develop software. I was inspired by the
support that I got from the team, which gave me the confidence to focus my energy on ZF development.
I would also like to thank the Apress team for sticking it out with me and keeping me on track. They
believed in me and the project even when I wasn’t sure.
Finally, I would like to thank Wil Sinclair for taking the time to give me a unique perspective into the
underlying process that went into the framework’s development.
Download at WoweBook.Com
xviii
Introduction

This book guides you through the process of developing a content management system with Zend
Framework. It utilizes a hands-on, step-by-step approach that introduces you to many of the core
components of the framework over the course of the project.
When the project is completed, you will have more than a simple CMS system; you will also have the
skills and experience that you need to customize this base to meet the requirements of much more
advanced and complicated projects.
Who This Book Is For
This book was written for PHP programmers who have at least some experience working with object-
oriented PHP. It would help to have some familiarity with Zend Framework, but you will learn a lot
about the framework over the course of the book.
Prerequisites
To follow along with the examples, you will need a computer on which you can install a local testing
server. In this book, I use Zend Server Community Edition, which is a free server that comes
preconfigured to work seamlessly with the framework.

I strongly recommend a professional IDE such as Zend Studio as well; it is true that many PHP
programmers get along fine with a simple text editor, but these object-oriented principles are much
easier to manage and develop with the proper software.
Download at WoweBook.Com
C H A P T E R 1
■ ■ ■
1
Getting Started
Before you get into building your CMS project, it is important to understand a few things about Zend
Framework (ZF). The core of ZF is a loosely coupled application framework that consists of a library of
components.
These components are all written in object-oriented PHP, closely following the current best
practices. They can be used independently, much like components in many other code libraries. For
example, a developer can use the Zend_Service_Amazon component without using the Zend_Db
abstraction layer.

What differentiates ZF from many other PHP code bases is the model-view-controller (MVC)
implementation. MVC is a pattern where an application is broken into three distinct parts:
• Business logic: The controller handles the logic behind the application.
• Data: The model handles managing the application data.
• Presentation: The view handles rendering the dynamic pages.
■ Note There are a number of differing opinions regarding the structure of an MVC application. The approach I
just described is referred to as the fat controller approach.
This pattern is rapidly becoming the standard for web application development, because this clean
separation makes complicated sites significantly easier to develop and maintain. This is particularly true
in the case of a development team; the developers can focus on their areas of expertise without having to
work 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. Bear in mind that ZF is a very flexible framework,
Download at WoweBook.Com
CHAPTER 1 ■ GETTING STARTED
2
and any of these components can be used on their own, but they provide a rich application platform
when used together.
The Controller: Zend_Controller_Front
Zend_Controller_Front implements the front controller pattern. All requests are ported through this
single point of entry, which is responsible for building and returning the response. The front controller’s
workflow consists of several components, which represent the following sequential process:
1. The request object (Zend_Controller_Request_Abstract): This represents the
unprocessed request and is responsible for evaluating the user request and

providing information about the request to the rest of the process.
2. The router (Zend_Controller_Router_Interface): The router inspects the request
object and then determines which controller and action should be run to process
the request. By default, the router breaks down the URL into the controller,
actions, and key/value pairs of parameters. For example,
http://localhost/user/profile/id/234 would be evaluated to the user controller
and profile action, and the parameter id would equal 234.
3. The dispatcher (Zend_Controller_Dispatcher_Interface): The dispatcher takes
the information that the router provides, instantiates the proper action
controller, and runs the action method. Bear in mind that this process occurs in a
loop and can happen several times during the scope of a request. This is
commonly used with modular applications that may run several actions prior to
returning the response. I often use this approach to enable developers to embed
the response from a module in a CMS page.
4. The response (Zend_Controller_Response_Abstract): The response object is
responsible for collecting and returning the responses from the controller
actions.
The Model: Zend_Db
A web application can serve data from many sources, but the most common source is a database.
Zend_Db provides a SQL database interface for ZF. A number of adapters for different database systems
are available that provide an abstraction layer to these databases. This abstraction layer enables you to
use a common set of tools for a range of different database systems.
Zend_Db_Table, which is the class that you will use to create your models, provides an object-
oriented interface to these database tables. It implements the Table Data Gateway pattern. This pattern
manages all the SQL for common database functions. This is a more generic approach to database
abstraction, as opposed to other ORM systems that map data objects and their relationships to a
relational database.
It also includes an implementation of the Row Data Gateway pattern, which creates data objects
that provide access to all the underlying information in a database row.
Download at WoweBook.Com

CHAPTER 1 ■ GETTING STARTED
3
The View: Zend_View
Zend_View is a lightweight class that provides the view for the ZF MVC implementation. The front
controller creates an instance of Zend_View, which maps to the action methods in the controller classes.
The action method sets view variables with data that it loads from the model, and then Zend_View takes
this data and generates the XHTML response. It includes a number of tools to make this process as
flexible as possible, including helpers and filters. Bear in mind that although Zend_View uses PHP as its
default template system, you can use it with a variety of different systems such as Smarty.
Setting Up Your Development Environment
The first thing you will need to set up for the framework is a development server to build and test your
projects on. There are a wide range of options for both Linux and Windows operating systems. One of
these solutions, which includes Zend Framework and command-line tools, is Zend Server. There are two
versions of this package: the community version and a commercial version that includes support,
updates, and additional features. For your local development environment, the community version
should suffice.
Installing Zend Server CE
Zend Server includes installers for both Linux and Windows. In this section, I will describe the
installation process for the Windows version.
First you need to get download the server installer. You can get the current download on the Zend
Server website (
Once you have downloaded the installer, start it, and you should see a screen that looks like
Figure 1-1.
Download at WoweBook.Com
CHAPTER 1 ■ GETTING STARTED
4

Figure 1-1. The Zend Server Windows installer
Click Next, and then read and agree to the license. Next you will be prompted to choose an
installation type. Select Custom, and click Next.

You can select any components that you want, but make sure that the following items are selected:
PHP
• Common Extensions
• Additional Extensions
Zend Framework
• Base
• Extras
MySQL server
Download at WoweBook.Com
CHAPTER 1 ■ GETTING STARTED
5
Once you have set up your components, click Next. Now select the option install the Apache server,
and click Next. The next step is to select the port for Apache to use. In most situations, you can just use
the default, port 80. Click Next and then Install to install the server. This may take some time because
there are a number of components that need to be downloaded before your installation can be
completed. Once the installation is completed, the installer will give you the option of starting to work
with Zend Server. Select this option, and click Finish. Your browser should open, and you will be
directed to the server administration page. The first time you load the server administration page, Zend
Server will prompt you for a password. Once you enter the password, you will be granted access to the
main server administration console.
Doing Rapid Application Development with the Zend Command-
Line 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 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
Download at WoweBook.Com

×