Advanced PHP programming: pattern, framework, and test
[Author] (plus) Kevin McArthur [same author's work] [Translator's introduction]
Translated by Wang Yong [same translator's work]
[Book name] Turing programming Series
[Release news agency] People's post and telecommunications Publishing House [book no.] 9787115193179
[Shelving time]
[Publication date] July 2009 [start] 16 open [Page code] 1 [version] 1-1
Market Price: ¥45.00
Member price: ¥33.75(Off)
Book 75 fold reservation and sample chapter trial: http://www.china-pub.com/195610
[Edit recommendations]
A prestigious advanced PHP tutorial.
Core developer masterpiece of Zend framework ..
In-depth design patterns, PHP standard libraries and JSON...
[Content Overview]
Today, PHP is the undisputed mainstream language for web development. After PHP 5, its object-oriented features are sufficient to compete with Java and C. However, the lack of information about PhP's advanced features has greatly affected the in-depth application of PHP ..
This book fills this gap. It specifically targets PHP programmers with certain experience and explains in detail their most important topics: advanced object-oriented, design patterns, documentation, testing, and standard PHP libraries. At the same time, to adapt to the new trend of web development, the author also comprehensively explores the MVC Architecture and Zend framework, as well as Ajax, JSON, soap, and other Web 2.0 technologies. The vast amount of practical software development experience and insights into PHP programming ideas interspersed in the book will greatly improve your internal skill ....
[Preface]
Over the past decade, PHP has transformed from a simple set of tools provided to web site developers to a Complete OOP language. In terms of Web application development, PHP can now compete with mainstream programming languages such as Java and C #. More and more companies use PHP to provide more powerful functions for websites. The reason is clear: PHP is both an easy-to-learn language and has powerful features.
By reading this book, you will gain an in-depth understanding of OOP theory and learn how to use frameworks and advanced system interoperability functions to maximize the power of PHP programming.
Target Audience
This is an advanced book. I carefully select the content that should be included in this book and the knowledge that readers should master. Readers should have a deep understanding of HTTP and PHP, that is, they should understand how to create web pages and web forms, and also understand key concepts such as the HTTP request lifecycle.
If you do not know about this, we recommend that you read the PHP for the Web: Visual Quickstart guide, co-authored by Larry Ullman. This is a very good book about PHP programming. Anyone who wants to become a PHP developer should definitely read it.
If your PHP programming level has reached the advanced level, this book is suitable for you.
Book Structure
The content of each chapter in this book is based on the previous chapter, and the reader's base is also considered to be uneven. If you think you have understood the content of a chapter, you are advised to skip that chapter, but you 'd better read the "summary" section at the end of each chapter, that is the summary of each chapter. However, even the most skilled programmers should have new gains in each chapter.
This book is divided into five parts.
The first part is OOP and pattern. This part is essential for learning advanced OOP concepts. This section directly goes to the topic and explains the abstract class, interface, static method, singleton and factory modes, and exceptions. Finally, the new features of Php 6 are introduced.
The second part is testing and documentation. This part includes all the related "peripheral" concepts, such as test-driven development and automatic deployment. This article describes how to compile excellent documents, and introduces phpdoc, docbook, and other document standards. This section also introduces the reflection API content, allowing readers to learn how to obtain metadata from a program. At last, we also discussed continuous integration and how to use tools such as phing and xinc to improve the development workflow.
Part 3: SPL (Standard PHP library ). SPL contains some of the most advanced PHP code. It provides language support for advanced OOP concepts such as the indexer and iterator, as well as a structure for exception handling, and a pattern like observer/publisher. This part of information allows you to create a more elegant and well-structured class.
Part 4: MVC mode. MVC (Model-View-Controller) may be the most useful development mode used by PHP developers. It can be used to create structures for applications and allocate the best resources in the team to complete the work. A deep understanding of this model may be the most important professional skill that any PHP developer must possess. Therefore, this book strives to fully explain this model. This section also introduces the Zend framework, which is a set of MVC-based frameworks accepted by many PHP companies. At the beginning, we introduced how to gradually build a complete framework application and run it. Then we explained the core concepts and advanced features of the Zend framework.
Part 5: Web 2.0. This section describes all the things that need to be learned about Web 2.0. You will learn about Ajax, JSON, soap web service, and ssl client verification. In addition, this part includes a large number of useful tutoring materials based on personal experience.
Contact author
You are welcome to contact the author at any time through email Kevin.McArthur@StormTide.ca. On the http: // www/. stormtide. ca/Pro-HPP-book or apress press site http://www.apress.com/book/view/9781590598191page, you can upload the latest information of this book. In addition, you can also access # PHP EFnet to chat with the author through IRC.
Thank you
This book is written on the basis of technical innovation in communities composed of thousands of developers over the past decade. I would like to thank all of them and pay tribute to them for their outstanding achievements in this book.
I would like to thank David Fugate for giving me the opportunity to write this book, as well as the necessary guidance for me in writing this book.
I would also like to thank Michael Geist for his help and suggestions so that I can solve the problem smoothly.
I must also thank my friends and family for their support. Without them, I cannot achieve these results.
Finally, I would like to express my sincere gratitude to everyone in the apress press. Some of them have participated in the publishing of this book, while others have helped other authors publish high-quality books. Without them, this book will not be available.
Contents
Part 1 OOP and Pattern
Chapter 2 abstract classes, interfaces, and contractual programming 2
1.1 abstract class 2
1.2 interface 4
1.3 instanceof operator 7
1.4 contractual programming 8
1.5 Summary 8
Chapter 9 static variables, members, and methods
2.1 static variable 9
2.2 Use of static elements in the class 10
2.2.1 static member 10
2.2.2 double colon (paamayim nekudow.im) 11
2.2.3 static method 14
2.3 "static" feature debate 15
2.4 Conclusion 15
Chapter 1 Singleton mode and factory mode 17
3.1 responsibilities and Singleton mode 17
3.2 factory model 19
3.2.1 image object factory 20
3.2.2 portable database 22
3.3 conclusion 24
Chapter 2 exception 26
4.1 Implementation exception 26
4.1.1 exception element 26
4.1.2 scaling exception 28
4.2 abnormal log recording 30
4.2.1 logs of custom exceptions 30
4.2.2 defining uncaptured Exception Handling Procedures 31
4.3 overhead caused by exceptions 31
4.4 error code 32
4.5 type prompts and exceptions 33
4.6 re-throw an exception 33
4.7 summary 34
Chapter 5 new features 35 in PHP 6
5.1 install PHP 35
5.2 Unicode in PHP 6 supports 37
5.2.1 Unicode semantics 37
5.2.2 Unicode sorting Rule 39
5.3 namespace 40
5.4 delayed static binding 41
5.5 static methods with dynamic characteristics 43
5.6 three-object operator (ifsetor) 43
5.7 xmlwriter Class 43
5.8 summary 45
Part 2 testing and documentation
Chapter 4 documentation and coding specifications 48
6.1 code specification 48
6.2 PHP comments and grammar parsing 49
6.2.1 annotation type 50
6.2.2 more information about document comments 50
6.2.3 grammar 51
6.2.4 metadata 51
6.3 phpdoc 52
6.4 docbook 55
6.4.1 XML used to create a docbook
File 55
6.4.2 parsing docbook file 56
6.4.3 use docbook element 59
6.5 Conclusion 62
Chapter 4 reflection API 64
7.1 reflection API Introduction 64
7.1.1 obtain user declared class 65
7.1.2 understand the plug-in architecture using reflection technology 66
7.2 parse reflection-based document data 71
7.2.1 install the document block splitter 72
7.2.2 access document comment Data 73
7.2.3 perform word segmentation for document comment Data 73
7.2.4 resolution identifier 74
7.3 extended reflection API 76
7.3.1 parser and reflection API integration 77
7.3.2 extended reflection class 78
7.3.3 update the parser to process intra-Row Labels 85
7.3.4 add feature 88
7.4 conclusion 92
Chapter 3 testing, deployment, and continuous integration 93
8.1 subversion 93 used for Version Control
8.1.1 install subversion 94
8.1.2 set subversion 94
8.1.3 submit modifications and resolve conflicts 95
8.1.4 activate the Subversion access function 97
8.2 phpunit 98 for unit testing
8.2.1 install phpunit 98
8.2.2 create the first unit test 98
8.2.3 understand phpunit 100
8.3 phing 102 for deployment
8.3.1 install phing 102
8.3.2 compile phing deployment script 103
8.4 xinc, continuous Integration Server 106
8.4.1 install xinc 106
8.4.2 create xinc profile 106
8.4.3 start xinc 107
8.5 xdebug 107 for debugging
8.5.1 install xdebug 108
8.5.2 use xdebug to trace code execution 108
8.5.3 use xdebug to perform benchmarking 110
8.5.4 use xdebug to check that the Code overwrites 110
8.5.5 use xdebug for remote debugging 111
8.6 Conclusion 111
Part 3 Spl (Standard PHP Library)
Chapter 2 SPL introduction 9th
9.1 SPL basics 114
9.2 iterator 115
9.2.1 iterator interface 115
9.2.2 iterator auxiliary function 116
9.3 array overload 117
9.3.1 arrayaccess API 117
9.3.2 count and array access 117
9.4 observer mode 118
9.5 serialization 121
9.6 SPL auto load 123
9.7 object identifier 126
9.8 conclusion 126
Chapter 2 SPL iterator 10th
10.1 iterator interface and iterator 128
10.1.1 iterator interface 128
10.1.2 iterator 130
10.2 actual usage of the iterator 142
10.2.1 use simplexml to parse XML
File 142
10.2.2 access a flat file using DBA
Database 143
10.3 conclusion 144
Chapter 4 SPL file and directory processing 11th
11.1 file and directory information 145
11.2 directory iterative access 147
11.2.1 listing files and directories 148
11.2.2 search for file 150
11.2.3 create a custom file filter iterator 151
11.3 SPL file object operations 153
11.3.1 iterative access to file content 153
11.3.2 CSV operation 153
11.3.3 search for file 157
11.4 conclusion 158
Chapter 2 SPL array overloading 12th
12.1 arrayaccess interface Introduction 160
12.2 arrayobject introduction 161
12.3 create an SPL shopping cart 162
12.4 use an object as the key value 165
12.5 Conclusion 168
Chapter 2 SPL exception 13th
13.1 logical exception 169
13.2 runtime exception 171
13.3 invalid function call exceptions and invalid Methods
Call exception 171
13.4 domain exception 172
13.5 range exception 172
13.6 invalid parameter exception 173
13.7 length exception 174
13.8 overflow exception 175
13.9 down overflow exception 175
13.10 conclusion 177
Part 4 MVC Mode
Chapter 2 MVC Architecture 14th
14.1 why MVC 180
14.2 MVC application layout 181
14.2.1 starting from Web Server 181
14.2.2 action and controller 182
14.2.3 model 182
14.2.4 view 182
14.3 select the MVC framework standard 182
14.3.1 architecture of the MVC Framework 182
14.3.2 MVC Framework 183
14.3.3 community of MVC Framework 183
14.3.4 support for the MVC Framework 183
14.3.5 MVC Framework 184 in flexibility
14.4 implement MVC Framework 184
14.4.1 set a VM 184
14.4.2 create an MVC Framework 185
14.5 conclusion 191
Chapter 2 Zend framework introduction 15th
15.1 set Zend framework 192
15.1.1 install Zend framework 192
15.1.2 create a VM 193
15.1.3 boot file 194
15.2 create controllers, views, and models 196
15.2.1 add an index controller 196
15.2.2 add view 196
15.2.3 define model 197
15.3 add function 200
15.3.1 use request and response
Object 201
15.3.2 use the built-in operation auxiliary class 202
15.3.3 use the built-in view helper class 203
15.3.4 verify input 204
15.4 conclusion 208
Chapter 2 advanced functions of the Zend framework 16th
16.1 manage the configuration file 209
16.1.1 use array method 209
16.1.2 ini 210
16.1.3 XML method 210
16.2 set the site-level view variable 211
16.3 shared object 211
16.4 error handling 212
16.5 application logging 213
16.6 cache 214
16.6.1 security considerations of the cache function 214
16.6.2 Cache Technology 215
16.7 verified users 217
16.8 use JSON 220 in PHP
16.9 custom route 221
16.10 manage sessions 223
16.11 send email 224
16.12 create a PDF file 225
16.12.1 create a new pdf page 226
16.12.2 drawing 226 on the pdf page
16.13 integration with Web Services 228
16.14 conclusion 229
Chapter 2 apply the Zend framework 17th
17.1 module and model settings 230
17.1.1 conventional modular directory structure 230
17.1.2 model library and zend_loader 231
17.2 request lifecycle 232
17.3 create a plug-in 233
17.4 create a helper class 234
17.4.1 write operation helper class 234
17.4.2 write view helper 234
17.5 implement the access control function 235
17.6 use two-step view 238
17.6.1 create a master layout 238
17.6.2 use placeholders 239
17.7 conclusion 240
Part 5 Web 2.0
Chapter 2 Ajax and JSON 18th
18.1 JSON and PHP 242
18.1.1 JSON expansion 243
JSON 244 in 18.1.2 Zend framework
18.2 JSON and JavaScript 244
18.3 some Ajax projects 248
18.3.1 GET request 248
18.3.2 post 249
18.4 conclusion 252
Chapter 2 Introduction to Web Services and soap 19th
19.1 introduction to PHP Web Service Architecture 253
19.2 introduction to WSDL 254
19.2.1 WSDL terminology 254
19.2.2 WSDL 254
19.3 introduction to soap 256
19.4 Use PHP soap extension 257
19.4.1 soapclient class methods and
Option 259
19.4.2 soapserver class methods and
Option 261
19.5 real example 261
19.6 conclusion 264
Chapter 2 advanced Web Services 20th
20.1 complex types 265
4.1.1.1 complex type example 265
V1.1.2 class ing 270
20.2 authentication 271
Protocol 2.1 HTTP verification 271
20172.2 communication key verification 271
272 client certificate verification
20.3 session 272
20.4 objects and persistence 273
20.5 binary data transmission 274
20.6 conclusion 276
Chapter 1 certificate verification 21st
21.1 PKI Security 277
21.1.1 ca 277
21.1.2 web server certificate 278
21.1.3 client certificate 278
21.1.4 CA certificate 278
21.2 Set client certificate verification 278
21.2.1 create a client certificate verification mechanism 279
21.2.2 create a self-Signed Web Service
Server certificate 281
21.2.3 configure Apache server 283 for SSL
21.2.4 create client certificate 284
21.2.5 only clients with Verified Certificates are allowed
Access Server 286
21.2.6 test certificate 287
21.3 PHP verification control 287
21.3.1 bind PHP to certificate 288
21.3.2 set web service verification 288
21.4 conclusion 289