Programmer's Reference Guide Zend Framework 0.8.0

fishhookFladgeInternet and Web Development

Dec 13, 2013 (3 years and 8 months ago)

459 views

Programmer's Reference Guide
Zend Framework 0.8.0
Table of Contents
Chapter 1. Zend
..................................................................................................................................
14
1.1. Introduction
...........................................................................................................................................
14
1.2. Zend::loadFile()
....................................................................................................................................
14
1.3. Zend::loadClass()
..................................................................................................................................
14
1.4. Zend::isReadable()
................................................................................................................................
15
1.5. Zend::exception()
..................................................................................................................................
15
1.6. Zend::dump()
........................................................................................................................................
15
1.7. Zend::register($index, $newval)
...........................................................................................................
16
1.8. Zend::registry($index = null)
................................................................................................................
16
1.9. Zend::initRegistry($registry = 'Zend_Registry')
...................................................................................
17
Chapter 2. Zend_Acl
..........................................................................................................................
18
2.1. Introduction
...........................................................................................................................................
18
2.1.1. About Resources
............................................................................................................................................
18
2.1.2. About Roles
...................................................................................................................................................
18
2.1.3. Creating the Access Control List (ACL)
.......................................................................................................
19
2.1.4. Registering Roles
..........................................................................................................................................
19
2.1.5. Defining Access Controls
..............................................................................................................................
20
2.1.6. Querying the ACL
.........................................................................................................................................
20
2.2. Refining Access Controls
......................................................................................................................
21
2.2.1. Precise Access Controls
................................................................................................................................
21
2.2.2. Removing Access Controls
...........................................................................................................................
22
2.3. Advanced Use
.......................................................................................................................................
23
2.3.1. Storing ACL Data for Persistence
.................................................................................................................
23
2.3.2. Writing Conditional ACL Rules with Assertions
..........................................................................................
23
Chapter 3. Zend_Auth
........................................................................................................................
24
3.1. Introduction
...........................................................................................................................................
24
3.1.1. Adapters
.........................................................................................................................................................
24
3.1.2. Results
...........................................................................................................................................................
25
3.1.3. Identity Persistence
.......................................................................................................................................
25
3.1.4. Using Zend_Auth
..........................................................................................................................................
25
3.2. Digest Authentication
............................................................................................................................
26
3.2.1. Introduction
...................................................................................................................................................
26
3.2.2. Specifics
........................................................................................................................................................
27
3.2.3. Identity
..........................................................................................................................................................
27
Chapter 4. Zend_Cache
......................................................................................................................
28
4.1. Introduction
...........................................................................................................................................
28
4.2. The theory of caching
...........................................................................................................................
30
4.2.1. The Zend_Cache factory method
..................................................................................................................
30
4.2.2. Tagging records
.............................................................................................................................................
31
4.2.3. Cleaning the cache
........................................................................................................................................
31
4.3. Zend_Cache frontends
..........................................................................................................................
31
4.3.1. Zend_Cache_Core
.........................................................................................................................................
31
4.3.1.1. Introduction
..........................................................................................................................................
31
4.3.1.2. Available options
..................................................................................................................................
32
4.3.1.3. Examples
..............................................................................................................................................
32
4.3.2. Zend_Cache_Frontend_Output
.....................................................................................................................
33
4.3.2.1. Introduction
..........................................................................................................................................
33
4.3.2.2. Available options
..................................................................................................................................
33
4.3.2.3. Examples
..............................................................................................................................................
33
4.3.3. Zend_Cache_Frontend_Function
..................................................................................................................
34
4.3.3.1. Introduction
..........................................................................................................................................
34
4.3.3.2. Available options
..................................................................................................................................
34
4.3.3.3. Examples
..............................................................................................................................................
34
4.3.4. Zend_Cache_Frontend_Class
........................................................................................................................
34
4.3.4.1. Introduction
..........................................................................................................................................
34
4.3.4.2. Available options
..................................................................................................................................
34
4.3.4.3. Examples
..............................................................................................................................................
35
4.3.5. Zend_Cache_Frontend_File
..........................................................................................................................
36
Page
2
of
324
Zend Framework 0.8.0
4.3.5.1. Introduction
..........................................................................................................................................
36
4.3.5.2. Available options
..................................................................................................................................
36
4.3.5.3. Examples
..............................................................................................................................................
36
4.3.6. Zend_Cache_Frontend_Page
........................................................................................................................
36
4.3.6.1. Introduction
..........................................................................................................................................
36
4.3.6.2. Available options (for this frontend in Zend_Cache factory)
...............................................................
36
4.3.6.3. Examples
..............................................................................................................................................
37
4.4. Zend_Cache backends
..........................................................................................................................
38
4.4.1. Zend_Cache_Backend_File
..........................................................................................................................
38
4.4.2. Zend_Cache_Backend_Sqlite
.......................................................................................................................
39
4.4.3. Zend_Cache_Backend_Memcached
.............................................................................................................
39
4.4.4. Zend_Cache_Backend_APC
.........................................................................................................................
40
4.4.5. Zend_Cache_Backend_ZendPlatform
..........................................................................................................
40
Chapter 5. Zend_Config
.....................................................................................................................
41
5.1. Introduction
...........................................................................................................................................
41
5.2. Theory of Operation
..............................................................................................................................
41
5.3. Zend_Config_Ini
...................................................................................................................................
42
5.4. Zend_Config_Xml
................................................................................................................................
43
Chapter 6. Zend_Console_Getopt
......................................................................................................
44
6.1. Introduction to Getopt
...........................................................................................................................
44
6.2. Declaring Getopt Rules
.........................................................................................................................
45
6.2.1. Declaring Options with the Short Syntax
......................................................................................................
45
6.2.2. Declaring Options with the Long Syntax
......................................................................................................
45
6.3. Fetching Options and Arguments
..........................................................................................................
46
6.3.1. Handling Getopt Exceptions
.........................................................................................................................
46
6.3.2. Fetching Options by Name
............................................................................................................................
46
6.3.3. Reporting Options
.........................................................................................................................................
47
6.3.4. Fetching Non-option Arguments
...................................................................................................................
47
6.4. Configuring Zend_Console_Getopt
......................................................................................................
47
6.4.1. Adding Option Rules
.....................................................................................................................................
47
6.4.2. Adding Help Messages
..................................................................................................................................
48
6.4.3. Adding Option Aliases
..................................................................................................................................
48
6.4.4. Adding Argument Lists
.................................................................................................................................
48
6.4.5. Adding Configuration
....................................................................................................................................
49
Chapter 7. Zend_Controller
................................................................................................................
51
7.1. Overview
...............................................................................................................................................
52
7.1.1. Introduction
...................................................................................................................................................
52
7.1.2. Request Object
..............................................................................................................................................
53
7.1.3. Route Process
................................................................................................................................................
53
7.1.4. Dispatch Process
...........................................................................................................................................
54
7.1.5. Response Object
............................................................................................................................................
54
7.2. Getting Started
......................................................................................................................................
55
7.2.1. Introduction
...................................................................................................................................................
55
7.2.2. Server Configuration
.....................................................................................................................................
55
7.2.3. Bootstrap File
................................................................................................................................................
56
7.2.4. Directory Structure
........................................................................................................................................
56
7.2.5. Default Controller
.........................................................................................................................................
57
7.3. Subclassing
...........................................................................................................................................
57
7.3.1. Introduction
...................................................................................................................................................
57
7.3.2. Conventions
...................................................................................................................................................
58
7.3.2.1. Prefix
....................................................................................................................................................
58
7.3.2.2. Directory Layout
...................................................................................................................................
58
7.3.3. Front Controller
.............................................................................................................................................
59
7.3.4. Request Abstract
............................................................................................................................................
63
7.3.5. Router Interface
.............................................................................................................................................
65
7.3.6. Dispatcher Interface
......................................................................................................................................
65
7.3.7. Action Controller
...........................................................................................................................................
66
7.3.8. Response Object
............................................................................................................................................
67
7.4. Provided Subclasses
..............................................................................................................................
69
7.4.1. Introduction
...................................................................................................................................................
69
7.4.2. Zend_Controller_Request_Http
....................................................................................................................
69
7.4.2.1. Introduction
..........................................................................................................................................
69
Page
3
of
324
Zend Framework 0.8.0
7.4.2.2. Accessing Request Data
........................................................................................................................
69
7.4.2.3. Base Url and subdirectories
..................................................................................................................
69
7.4.3. Zend_Controller_Router_Rewrite
.................................................................................................................
70
7.4.3.1. Introduction
..........................................................................................................................................
70
7.4.3.2. Using a router
.......................................................................................................................................
70
7.4.3.3. Basic Routes
.........................................................................................................................................
71
7.4.3.4. Variable defaults
...................................................................................................................................
71
7.4.3.5. Variable requirements
...........................................................................................................................
72
7.4.3.6. Base URL and subdirectories
...............................................................................................................
72
7.4.3.7. Default routes
.......................................................................................................................................
72
7.4.3.8. Static Routes
.........................................................................................................................................
73
7.4.3.9. Using Zend_Config with the RewriteRouter
........................................................................................
73
7.4.4. Zend_Controller_Response_Http
..................................................................................................................
74
7.4.5. Zend_Controller_Response_Cli
....................................................................................................................
74
7.5. Action Controllers
.................................................................................................................................
74
7.5.1. Introduction
...................................................................................................................................................
74
7.5.2. Object initialization
.......................................................................................................................................
74
7.5.3. Pre- and Post-Dispatch Hooks
.......................................................................................................................
75
7.5.4. Accessors
.......................................................................................................................................................
75
7.5.5. Utility Methods
.............................................................................................................................................
75
7.6. Plugins
...................................................................................................................................................
75
7.6.1. Introduction
...................................................................................................................................................
75
7.6.2. Writing Plugins
..............................................................................................................................................
76
7.6.3. Using Plugins
................................................................................................................................................
76
7.7. Using a Conventional Modular Directory Structure
.............................................................................
77
7.7.1. Introduction
...................................................................................................................................................
77
7.7.2. Specifying Module Controller Directories
....................................................................................................
77
7.7.3. Routing to modules
.......................................................................................................................................
78
7.7.4. Module or Global Default Controller
............................................................................................................
78
7.8. MVC Exceptions
...................................................................................................................................
78
7.8.1. Introduction
...................................................................................................................................................
78
7.8.2. How can you handle exceptions?
..................................................................................................................
78
7.8.3. MVC Exceptions You May Encounter
..........................................................................................................
79
7.9. Migrating from Previous Versions
........................................................................................................
81
7.9.1. Migrating from 0.6.0 to 0.8.0
........................................................................................................................
81
7.9.2. Migrating from 0.2.0 or before to 0.6.0
........................................................................................................
82
Chapter 8. Zend_Date
.........................................................................................................................
84
8.1. Introduction
...........................................................................................................................................
84
8.1.1. Always Set a Default Timezone
....................................................................................................................
84
8.1.2. Why Use Zend_Date?
...................................................................................................................................
85
8.2. Basic Methods
.......................................................................................................................................
85
8.2.1. The current date
.............................................................................................................................................
85
8.2.2. Zend_Date by Example
.................................................................................................................................
86
8.2.2.1. Ouput a Date
.........................................................................................................................................
86
8.2.2.2. Setting a Date
........................................................................................................................................
86
8.2.2.3. Adding and Subtracting Dates
..............................................................................................................
86
8.2.2.4. Comparation of dates
............................................................................................................................
86
8.3. Theory of Operation
..............................................................................................................................
87
8.3.1. Internals
.........................................................................................................................................................
87
8.4. Zend_Date API Overview
.....................................................................................................................
88
8.4.1. Working with Date Values
.............................................................................................................................
88
8.4.2. Basic Zend_Date Operations Common to Many Date Parts
.........................................................................
88
8.4.2.1. List of Date Parts
..................................................................................................................................
89
8.4.2.2. List of Date Operations
.........................................................................................................................
90
8.4.3. Comparing Dates
...........................................................................................................................................
90
8.4.4. Getting Dates and Date Parts
........................................................................................................................
91
8.4.5. Working with Fractions of Seconds
..............................................................................................................
92
8.4.6. Sunrise / Sunset
.............................................................................................................................................
92
8.5. Constants for General Date Functions
..................................................................................................
92
8.5.1. Using Constants
.............................................................................................................................................
92
8.5.2. List of All Constants
......................................................................................................................................
93
8.5.3. Self-Defined OUTPUT Formats
...................................................................................................................
96
Chapter 9. Zend_Db
...........................................................................................................................
99
Page
4
of
324
Zend Framework 0.8.0
9.1. Zend_Db_Adapter
.................................................................................................................................
99
9.1.1. Introduction
...................................................................................................................................................
99
9.1.2. Quoting Against SQL Injection
...................................................................................................................
100
9.1.3. Direct Queries
.............................................................................................................................................
101
9.1.4. Transactions
.................................................................................................................................................
102
9.1.5. Inserting Rows
.............................................................................................................................................
102
9.1.6. Updating Rows
............................................................................................................................................
103
9.1.7. Deleting Rows
.............................................................................................................................................
103
9.1.8. Fetching Rows
.............................................................................................................................................
103
9.2. Zend_Db_Profiler
...............................................................................................................................
104
9.2.1. Introduction
.................................................................................................................................................
104
9.2.2. Using the Profiler
........................................................................................................................................
105
9.2.3. Advanced Profiler Usage
.............................................................................................................................
106
9.2.3.1. Filter by query elapsed time
...............................................................................................................
106
9.2.3.2. Filter by query type
.............................................................................................................................
106
9.2.3.3. Retrieve profiles by query type
...........................................................................................................
107
9.3. Zend_Db_Select
..................................................................................................................................
107
9.3.1. Introduction
.................................................................................................................................................
107
9.3.2. Columns FROM a Table
..............................................................................................................................
108
9.3.3. Columns from JOINed Tables
.....................................................................................................................
109
9.3.4. WHERE Conditions
....................................................................................................................................
110
9.3.5. GROUP BY Clause
.....................................................................................................................................
110
9.3.6. HAVING Conditions
...................................................................................................................................
111
9.3.7. ORDER BY Clause
.....................................................................................................................................
111
9.3.8. LIMIT By Count and Offset
........................................................................................................................
112
9.3.9. LIMIT By Page And Count
.........................................................................................................................
113
9.3.10. Other methods
...........................................................................................................................................
113
9.4. Zend_Db_Table
...................................................................................................................................
114
9.4.1. Introduction
.................................................................................................................................................
114
9.4.2. Getting Started
.............................................................................................................................................
115
9.4.3. Table Name and Primary Key
.....................................................................................................................
115
9.4.4. Inserting Rows
.............................................................................................................................................
116
9.4.5. Updating Rows
............................................................................................................................................
116
9.4.6. Deleting Rows
.............................................................................................................................................
117
9.4.7. Finding Rows by Primary Key
....................................................................................................................
117
9.4.8. Fetching One Row
.......................................................................................................................................
117
9.4.9. Fetching Multiple Rows
..............................................................................................................................
118
9.4.10. Adding Domain Logic
...............................................................................................................................
118
9.5. Zend_Db_Table_Row
.........................................................................................................................
119
9.5.1. Introduction
.................................................................................................................................................
119
9.5.2. Fetching a Row
............................................................................................................................................
119
9.5.3. Modifying Values
........................................................................................................................................
120
9.6. Zend_Db_Table_Rowset
.....................................................................................................................
121
9.6.1. Introduction
.................................................................................................................................................
121
9.6.2. Fetching a Rowset
.......................................................................................................................................
121
9.6.3. Iterating Through the Rowset
......................................................................................................................
121
Chapter 10. Zend_Feed
....................................................................................................................
123
10.1. Introduction
.......................................................................................................................................
123
10.2. Importing Feeds with Zend_Feed
.....................................................................................................
124
10.3. Retrieving Feeds from Web Pages
....................................................................................................
124
10.4. Consuming an RSS Feed
..................................................................................................................
124
10.5. Consuming an Atom Feed
.................................................................................................................
126
10.6. Consuming a Single Atom Entry
......................................................................................................
127
10.7. Modifying Feed and Entry structures
...............................................................................................
127
10.8. Custom Feed and Entry Classes
........................................................................................................
128
Chapter 11. Zend_Filter
....................................................................................................................
130
11.1. Introduction
.......................................................................................................................................
130
11.2. Filter Chains
......................................................................................................................................
130
11.3. Writing Filters
...................................................................................................................................
131
11.4. Zend_Filter_Input
.............................................................................................................................
131
11.4.1. Introduction
...............................................................................................................................................
131
11.4.2. Theory of Operation
..................................................................................................................................
132
Page
5
of
324
Zend Framework 0.8.0
Chapter 12. Zend_Gdata
...................................................................................................................
133
12.1. Introduction to Gdata
........................................................................................................................
133
12.1.1. Google Data Client Authentication
...........................................................................................................
134
12.1.2. Dependencies
............................................................................................................................................
134
12.1.3. Creating a new Gdata client
......................................................................................................................
134
12.1.4. Common query parameters
.......................................................................................................................
134
12.1.5. Fetching a feed
..........................................................................................................................................
135
12.1.6. Posting entries to Google servers
..............................................................................................................
135
12.1.7. Deleting entries on Google servers
...........................................................................................................
136
12.2. Authenticating with AuthSub
............................................................................................................
136
12.2.1. Creating an AuthSub authenticated Http Client
........................................................................................
137
12.2.2. Revoking AuthSub authentication
.............................................................................................................
137
12.3. Authenticating with ClientLogin
.......................................................................................................
138
12.3.1. Creating a ClientLogin authenticated Http Client
.....................................................................................
138
12.3.2. Terminating a ClientLogin authenticated Http Client
...............................................................................
138
12.4. Using Google Base
...........................................................................................................................
139
12.4.1. Querying Base data
...................................................................................................................................
139
12.4.2. Updating Base data
....................................................................................................................................
139
12.4.3. Querying Base metadata
............................................................................................................................
140
12.5. Using Google Blogger
......................................................................................................................
140
12.5.1. Understanding Blogger version compatibility
..........................................................................................
140
12.5.2. Querying a blog
.........................................................................................................................................
141
12.5.3. Posting to your blog
..................................................................................................................................
141
12.6. Using Google Calendar
.....................................................................................................................
142
12.6.1. Querying Google Calendar
........................................................................................................................
142
12.6.1.1. Event visibility
..................................................................................................................................
142
12.6.1.2. Event data projection
........................................................................................................................
142
12.6.1.3. Event dates
........................................................................................................................................
143
12.6.1.4. List calendars
....................................................................................................................................
143
12.6.2. Posting to Google Calendar
.......................................................................................................................
143
12.7. Using Google CodeSearch
................................................................................................................
144
12.8. Using the Gdata Data Helper
............................................................................................................
144
12.9. Catching Gdata Exceptions
...............................................................................................................
144
Chapter 13. Zend_Http
.....................................................................................................................
146
13.1. Zend_Http_Client - Introduction
......................................................................................................
146
13.1.1. Introduction
...............................................................................................................................................
146
13.1.2. Configuration Parameters
..........................................................................................................................
147
13.1.3. Performing Basic HTTP Requests
.............................................................................................................
147
13.1.4. Adding GET and POST parameters
.........................................................................................................
148
13.2. Zend_Http_Client - Advanced Usage
...............................................................................................
148
13.2.1. HTTP Redirections
....................................................................................................................................
148
13.2.2. Adding Cookies and Using Cookie Persistence
........................................................................................
149
13.2.3. Setting Custom Request Headers
..............................................................................................................
150
13.2.4. File Uploads
..............................................................................................................................................
150
13.2.5. Sending Raw POST Data
..........................................................................................................................
151
13.2.6. HTTP Authentication
.................................................................................................................................
151
13.2.7. Sending Multiple Requests With the Same Client
....................................................................................
151
13.3. Zend_Http_Client - Connection Adapters
........................................................................................
152
13.3.1. Overview
...................................................................................................................................................
152
13.3.2. The Socket Adapter
...................................................................................................................................
153
13.3.3. The Proxy Adapter
.....................................................................................................................................
153
13.3.4. The Test Adapter
........................................................................................................................................
154
13.3.5. Creating your own connection adapters
....................................................................................................
155
13.4. Zend_Http_Cookie and Zend_Http_CookieJar
................................................................................
157
13.4.1. Introduction
...............................................................................................................................................
157
13.4.2. Instantiating Zend_Http_Cookie Objects
..................................................................................................
157
13.4.3. Zend_Http_Cookie getter methods
...........................................................................................................
158
13.4.4. Zend_Http_Cookie: Matching against a scenario
.....................................................................................
159
13.4.5. The Zend_Http_CookieJar Class: Instantiation
........................................................................................
160
13.4.6. Adding Cookies to a Zend_Http_CookieJar object
...................................................................................
160
13.4.7. Retrieving Cookies From a Zend_Http_CookieJar object
........................................................................
160
13.5. Zend_Http_Response
........................................................................................................................
161
Page
6
of
324
Zend Framework 0.8.0
13.5.1. Introduction
...............................................................................................................................................
161
13.5.2. Boolean Tester Methods
............................................................................................................................
161
13.5.3. Accessor Methods
.....................................................................................................................................
162
13.5.4. Static HTTP Response Parsers
..................................................................................................................
163
Chapter 14. Zend_Json
.....................................................................................................................
164
14.1. Introduction
.......................................................................................................................................
164
14.2. Basic Usage
.......................................................................................................................................
164
14.3. JSON Objects
....................................................................................................................................
164
Chapter 15. Zend_Locale
.................................................................................................................
165
15.1. Introduction
.......................................................................................................................................
165
15.1.1. What is Localization
..................................................................................................................................
166
15.1.2. What is a Locale?
....................................................................................................................................
166
15.1.3. How are Locales Represented?
.................................................................................................................
166
15.1.4. Selecting the Right Locale
........................................................................................................................
167
15.1.5. ZF Locale-Aware Classes
..........................................................................................................................
167
15.2. Using Zend_Locale
...........................................................................................................................
168
15.2.1. Copying, Cloning, and Serializing Locale Objects
...................................................................................
168
15.2.2. isEqual() - Equality
...................................................................................................................................
168
15.2.3. Default locales
...........................................................................................................................................
168
15.2.4. Set a new locale
.........................................................................................................................................
169
15.2.5. Getting the language and region
................................................................................................................
169
15.2.6. Obtaining localized name for languages, regions, and calendars
..............................................................
169
15.2.7. Get an translated string of an script
...........................................................................................................
170
15.2.8. Get a list of scripts
.....................................................................................................................................
170
15.2.9. Obtaining translations for "yes" and "no"
.................................................................................................
171
15.3. Normalization and Localization
........................................................................................................
171
15.3.1. Number normalization: getNumber($input, $precision = false, $locale = false)
......................................
171
15.3.1.1. Precision and Calculations
................................................................................................................
172
15.3.2. Number localization
..................................................................................................................................
172
15.3.3. Number testing
..........................................................................................................................................
172
15.3.4. Float value normalization
..........................................................................................................................
173
15.3.5. Floating point value localization
...............................................................................................................
173
15.3.6. Floating point value testing
.......................................................................................................................
173
15.3.7. Integer value normalization
.......................................................................................................................
174
15.3.8. Integer point value localization
.................................................................................................................
174
15.3.9. Integer value testing
..................................................................................................................................
174
15.3.10. Numeral System Conversion
...................................................................................................................
174
15.3.10.1. List of supported numeral systems
.................................................................................................
175
15.4. Working with Dates and Times
.........................................................................................................
175
15.4.1. Normalizing Dates and Times
...................................................................................................................
176
15.4.2. Testing Dates
.............................................................................................................................................
178
15.4.3. Normalizing a Time
...................................................................................................................................
178
15.4.4. Testing Times
.............................................................................................................................................
179
15.5. Supported Languages for Locales
.....................................................................................................
179
15.6. Supported Regions for Locales
.........................................................................................................
181
Chapter 16. Zend_Log
......................................................................................................................
185
16.1. Introduction
.......................................................................................................................................
185
16.2. Logging to a Single Log
...................................................................................................................
185
16.3. Log Levels
........................................................................................................................................
185
16.4. Advanced Logging: Multiple Loggers
..............................................................................................
186
Chapter 17. Zend_Mail
.....................................................................................................................
187
17.1. Introduction
.......................................................................................................................................
187
17.2. Sending via SMTP
............................................................................................................................
187
17.3. Sending Multiple Mails per SMTP Connection
................................................................................
188
17.4. Using Different Transports
................................................................................................................
188
17.5. HTML E-Mail
...................................................................................................................................
189
17.6. Attachments
.......................................................................................................................................
189
17.7. Adding Recipients
.............................................................................................................................
189
17.8. Controlling the MIME Boundary
......................................................................................................
190
17.9. Additional Headers
............................................................................................................................
190
17.10. Character Sets
.................................................................................................................................
190
Page
7
of
324
Zend Framework 0.8.0
17.11. Encoding
.........................................................................................................................................
190
17.12. SMTP Authentication
......................................................................................................................
190
17.13. Securing SMTP Transport
...............................................................................................................
191
17.14. Reading Mail Messages
..................................................................................................................
191
17.14.1. Simple example using Pop3
....................................................................................................................
192
17.14.2. Opening a local storage
...........................................................................................................................
192
17.14.3. Opening a remote storage
........................................................................................................................
192
17.14.4. Fetching messages and simple methods
..................................................................................................
193
17.14.5. Working with messages
...........................................................................................................................
193
17.14.6. Using folders
...........................................................................................................................................
195
17.14.7. Advanced Use
..........................................................................................................................................
196
17.14.7.1. Using NOOP
...................................................................................................................................
196
17.14.7.2. Caching instances
...........................................................................................................................
196
17.14.7.3. Extending Protocol Classes
............................................................................................................
197
Chapter 18. Zend_Measure
..............................................................................................................
199
18.1. Introduction
.......................................................................................................................................
199
18.2. Creation of Measurements
................................................................................................................
200
18.2.1. Creating measurements from integers and floats
......................................................................................
200
18.2.2. Creating measurements from strings
.........................................................................................................
200
18.2.3. Measurements from localized strings
........................................................................................................
201
18.3. Outputting measurements
.................................................................................................................
201
18.3.1. Automatic output
.......................................................................................................................................
201
18.3.2. Outputting values
......................................................................................................................................
202
18.3.3. Output with unit of measurement
..............................................................................................................
202
18.3.4. Output as localized string
..........................................................................................................................
202
18.4. Manipulating Measurements
.............................................................................................................
202
18.4.1. Convert
......................................................................................................................................................
202
18.4.2. Add and subtract
........................................................................................................................................
203
18.4.3. Compare
....................................................................................................................................................
203
18.4.4. Compare
....................................................................................................................................................
204
18.4.5. Manually change values
............................................................................................................................
204
18.4.6. Manually change types
..............................................................................................................................
205
18.5. Special functions
...............................................................................................................................
205
18.5.1. Listing all known types
.............................................................................................................................
205
18.5.2. Listing all known units
..............................................................................................................................
205
18.6. Types of measurements
.....................................................................................................................
205
18.6.1. Hints for Zend_Measure_Binary
...............................................................................................................
207
18.6.2. Hints for Zend_Measure_Number
............................................................................................................
207
18.6.3. Roman numbers
.........................................................................................................................................
207
Chapter 19. Zend_Mime
...................................................................................................................
208
19.1. Zend_Mime
.......................................................................................................................................
208
19.1.1. Introduction
...............................................................................................................................................
208
19.1.2. Static Methods and Constants
...................................................................................................................
208
19.1.3. Instantiating Zend_Mime
..........................................................................................................................
208
19.2. Zend_Mime_Message
.......................................................................................................................
209
19.2.1. Introduction
...............................................................................................................................................
209
19.2.2. Instantiation
...............................................................................................................................................
209
19.2.3. Adding MIME Parts
..................................................................................................................................
209
19.2.4. Boundary handling
....................................................................................................................................
209
19.2.5. parsing a string to create a Zend_Mime_Message object (experimental)
.................................................
209
19.3. Zend_Mime_Part
..............................................................................................................................
210
19.3.1. Introduction
...............................................................................................................................................
210
19.3.2. Instantiation
...............................................................................................................................................
210
19.3.3. Methods for rendering the message part to a string
..................................................................................
210
Chapter 20. Zend_Pdf
.......................................................................................................................
211
20.1. Introduction.
......................................................................................................................................
211
20.2. Creating and loading PDF documents.
..............................................................................................
211
20.3. Save changes to the PDF document.
.................................................................................................
212
20.4. Document pages.
...............................................................................................................................
213
20.5. Drawing.
............................................................................................................................................
213
20.5.1. Geometry.
..................................................................................................................................................
213
20.5.2. Colors.
.......................................................................................................................................................
214
Page
8
of
324
Zend Framework 0.8.0
20.5.3. Shape Drawing.
.........................................................................................................................................
214
20.5.4. Text Drawing.
............................................................................................................................................
215
20.5.5. Using fonts.
...............................................................................................................................................
216
20.5.6. Image Drawing.
.........................................................................................................................................
218
20.5.7. Line drawing style.
....................................................................................................................................
219
20.5.8. Fill style.
....................................................................................................................................................
219
20.5.9. Rotations.
...................................................................................................................................................
220
20.5.10. Save/restore graphics state.
.....................................................................................................................
220
20.5.11. Clipping draw area.
.................................................................................................................................
221
20.5.12. Styles.
......................................................................................................................................................
222
20.6. Zend_Pdf module usage example.
....................................................................................................
224
Chapter 21. Zend_Rest
.....................................................................................................................
226
21.1. Introduction
.......................................................................................................................................
226
21.2. Zend_Rest_Client
.............................................................................................................................
226
21.2.1. Introduction
...............................................................................................................................................
226
21.2.2. Responses
..................................................................................................................................................
227
21.2.3. Request Arguments
....................................................................................................................................
228
21.3. Zend_Rest_Server
.............................................................................................................................
228
21.3.1. Introduction
...............................................................................................................................................
228
21.3.2. REST Server Usage
...................................................................................................................................
228
21.3.3. Calling a Zend_Rest_Server Service
.........................................................................................................
229
21.3.4. Sending A Custom Status
..........................................................................................................................
229
21.3.5. Returning Custom XML Responses
..........................................................................................................
230
Chapter 22. Zend_Search
.................................................................................................................
231
22.1. Overview
...........................................................................................................................................
231
22.1.1. Introduction
...............................................................................................................................................
231
22.1.2. Document and Field Objects
.....................................................................................................................
232
22.1.3. Understanding Field Types
........................................................................................................................
233
22.2. Building Indexes
...............................................................................................................................
233
22.2.1. Creating a New Index
................................................................................................................................
233
22.2.2. Updating Index
..........................................................................................................................................
234
22.2.3. Updating Documents
.................................................................................................................................
234
22.2.4. Retrieving Index size
.................................................................................................................................
234
22.2.5. Index optimization
.....................................................................................................................................
235
22.2.5.1. MaxBufferedDocs auto-optimization option
....................................................................................
235
22.2.5.2. MaxMergeDocs auto-optimization option
........................................................................................
235
22.2.5.3. MergeFactor auto-optimization option
.............................................................................................
235
22.2.6. Limitationas
...............................................................................................................................................
236
22.3. Searching an Index
............................................................................................................................
236
22.3.1. Building Queries
.......................................................................................................................................
236
22.3.1.1. Query parsing
...................................................................................................................................
236
22.3.2. Search Results
...........................................................................................................................................
237
22.3.3. Results Scoring
..........................................................................................................................................
238
22.3.4. Search Result Sorting
................................................................................................................................
238
22.4. Query Language
................................................................................................................................
239
22.4.1. Terms
.........................................................................................................................................................
239
22.4.2. Fields
.........................................................................................................................................................
239
22.4.3. Term Modifiers
..........................................................................................................................................
240
22.4.4. Proximity Searches
....................................................................................................................................
240
22.4.5. Boosting a Term
........................................................................................................................................
240
22.4.6. Boolean Operators
.....................................................................................................................................
240
22.4.6.1. AND
..................................................................................................................................................
240
22.4.6.2. OR
.....................................................................................................................................................
241
22.4.6.3. NOT
..................................................................................................................................................
241
22.4.6.4. &&, ||, and ! operators
......................................................................................................................
241
22.4.6.5. +
........................................................................................................................................................
241
22.4.6.6. -
.........................................................................................................................................................
241
22.4.6.7. no operator
........................................................................................................................................
241
22.4.7. Grouping
....................................................................................................................................................
241
22.4.8. Field Grouping
..........................................................................................................................................
242
22.4.9. Escaping Special Characters
.....................................................................................................................
242
22.5. Query Construction API
....................................................................................................................
242
22.5.1. Query Parser Exceptions
...........................................................................................................................
242
Page
9
of
324
Zend Framework 0.8.0
22.5.2. Term Query
................................................................................................................................................
242
22.5.3. Multi-Term Query
.....................................................................................................................................
243
22.5.4. Phrase Query
.............................................................................................................................................
243
22.6. Character set.
.....................................................................................................................................
246
22.6.1. UTF-8 and single-byte character sets support.
..........................................................................................
246
22.6.2. Default text analyzer.
.................................................................................................................................
246
22.6.3. UTF-8 compatible text analyzer.
...............................................................................................................
246
22.7. Extensibility
......................................................................................................................................
247
22.7.1. Text Analysis
.............................................................................................................................................
247
22.7.2. Tokens Filtering
.........................................................................................................................................
249
22.7.3. Scoring Algorithms
...................................................................................................................................
249
22.7.4. Storage Containers
....................................................................................................................................
250
22.8. Interoperating with Java Lucene
.......................................................................................................
253
22.8.1. File Formats
...............................................................................................................................................
253
22.8.2. Index Directory
.........................................................................................................................................
253
22.8.3. Java Source Code
......................................................................................................................................
253
22.8.4. Using LuceneIndexCreation.jar
................................................................................................................
254
Chapter 23. Zend_Server
..................................................................................................................
255
23.1. Introduction
.......................................................................................................................................
255
23.2. Zend_Server_Reflection
...................................................................................................................
255
23.2.1. Introduction
...............................................................................................................................................
255
23.2.2. Usage
.........................................................................................................................................................
255
Chapter 24. Zend_Service
................................................................................................................
256
24.1. Introduction
.......................................................................................................................................
256
24.2. Zend_Service_Akismet
.....................................................................................................................
256
24.2.1. Introduction
...............................................................................................................................................
256
24.2.2. Verify an API key
......................................................................................................................................
257
24.2.3. Check for spam
..........................................................................................................................................
257
24.2.4. Submitting known spam
............................................................................................................................
258
24.2.5. Submitting false positives (ham)
...............................................................................................................
258
24.2.6. Zend-specific Accessor Methods
..............................................................................................................
258
24.3. Zend_Service_Amazon
.....................................................................................................................
259
24.3.1. Introduction
...............................................................................................................................................
259
24.3.2. Country Codes
...........................................................................................................................................
260
24.3.3. Looking up a Specific Amazon Item by ASIN
..........................................................................................
260
24.3.4. Performing Amazon Item Searches
...........................................................................................................
260
24.3.5. Using the Alternative Query API
..............................................................................................................
261
24.3.5.1. Introduction
......................................................................................................................................
261
24.3.6. Zend_Service_Amazon Classes
................................................................................................................
261
24.3.6.1. Zend_Service_Amazon_Item
...........................................................................................................
261
24.3.6.1.1. Zend_Service_Amazon_Item::asXML()
.................................................................................
261
24.3.6.1.2. Properties
.................................................................................................................................
261
24.3.6.2. Zend_Service_Amazon_Image
.........................................................................................................
262
24.3.6.2.1. Properties
.................................................................................................................................
262
24.3.6.3. Zend_Service_Amazon_ResultSet
...................................................................................................
262
24.3.6.3.1. Zend_Service_Amazon_ResultSet::totalResults()
...................................................................
263
24.3.6.4. Zend_Service_Amazon_OfferSet
.....................................................................................................
263
24.3.6.4.1. Properties
.................................................................................................................................
263
24.3.6.5. Zend_Service_Amazon_Offer
..........................................................................................................
263
24.3.6.5.1. Zend_Service_Amazon_Offer Properties
................................................................................
263
24.3.6.6. Zend_Service_Amazon_SimilarProduct
..........................................................................................
263
24.3.6.6.1. Properties
.................................................................................................................................
264
24.3.6.7. Zend_Service_Amazon_Accessories
...............................................................................................
264
24.3.6.7.1. Properties
.................................................................................................................................
264
24.3.6.8. Zend_Service_Amazon_CustomerReview
.......................................................................................
264
24.3.6.8.1. Properties
.................................................................................................................................
264
24.3.6.9. Zend_Service_Amazon_EditorialReview
........................................................................................
264
24.3.6.9.1. Properties
.................................................................................................................................
264
24.3.6.10. Zend_Service_Amazon_Listmania
.................................................................................................