Expert PHP 5 Tools Packt Open Source Project Royalties

Expert PHP 5 Tools Packt Open Source Project Royalties

Expert PHP 5 Tools Proven enterprise development tools and best practices for designing, coding, testing, and deploying PHP applications Dirk Merkel BIRMINGHAM - MUMBAI Download from Wow! eBook www.WoweBook.com Expert PHP 5 Tools Copyright © 2010 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: April 2010 Production Reference: 1240310 Published by Packt Publishing Ltd. 32 Lincoln Road Olton Birmingham, B27 6PA, UK. ISBN 978-1-847198-38-9 www.packtpub.com Cover Image by Karl Swedberg ([email protected]) Download from Wow! eBook www.WoweBook.com Credits Author Editorial Team Leader Dirk Merkel Gagandeep Singh Reviewers Project Team Leader Andrew J. Peterson Lata Basantani Deepak Vohra Project Coordinator Acquisition Editor Joel Goveya Douglas Paterson Proofreader Development Editor Claire Cresswell-Lane Ved Prakash Jha Graphics Technical Editor Geetanjali Sawant Neha Damle Production Coordinator Indexer Shantanu Zagade Monica Ajmera Melwyn D'sa Cover Work Melwyn D'sa Download from Wow! eBook www.WoweBook.com About the Author Dirk Merkel has been developing software in a variety of programming languages for many years, including PHP, Java, Perl, and Ruby. His focus has been on web-related technologies and he has over 10 years experience coding in PHP. He has experience covering the whole software development cycle and has been managing several teams of developers working on large-scale projects. He has been working as a professional consultant through his company Waferthin Web Works LLC (http://www.waferthin.com) and can be reached at [email protected]. He is also the Chief Technology Officer at VivanTech Inc., a San Diego based provider of IT solutions. He has written several articles on software development and security. Expert PHP 5 Tools is his first book. He lives in San Diego with his lovely wife and two wonderful daughters. I would like to thank my family (near and far)—especially my parents and sisters, my lovely wife, Rania, and my two awesome daughters, Nadia and Yasmin. Download from Wow! eBook www.WoweBook.com About the Reviewers Andrew J. Peterson lives with his wife and three daughters in San Francisco, California. He has 20 years experience building and managing software systems for consumers, enterprises, start-ups, and non-profits. He brings expertise in the full life-cycle of software development, engineering, methodologies, architecture, and usability. He has diverse experience in the industry. In the consumer space, he led a team in the creation of the top-selling SoundEdit 16. He served numerous roles producing enterprise software, for the leading supplier of software solutions for container terminals, shipping ports and lines, and distribution centers. Over the past ten years, he transferred this experience to web-based software. He has built a variety of web applications, including non-profit, social networking, social search, pharmaceuticals and social ecommerce. He has build successful projects in a variety of languages, including Java, Ruby, C++, Ruby and Perl. In the primal days of the Web, he wrote a manual helping users connect their Macintosh to the Web. More recently, he reviewed PHP and Scriptaculous Web Application Interfaces for Packt Publishing. I'd like to thank my wife for the bliss she brings. Deepak Vohra is a consultant and a principal member of the NuBean.com software company. Deepak is a Sun Certified Java Programmer and Web Component Developer, and has worked in the fields of XML and Java programming and J2EE for over five years. Deepak is the co-author of the Apress book Pro XML Development with Java Technology and was the technical reviewer for the O'Reilly book WebLogic: The Definitive Guide. Deepak was also the technical reviewer for the Course Technology PTR book Ruby Programming for the Absolute Beginner, and the technical editor for the Manning Publications book Prototype and Scriptaculous in Action. Deepak is also the author of the Packt Publishing books JDBC 4.0 and Oracle JDeveloper for J2EE Development and Processing XML Documents with Oracle JDeveloper 11g. Download from Wow! eBook www.WoweBook.com Download from Wow! eBook www.WoweBook.com Table of Contents Preface 1 Chapter 1: Coding Style and Standards 5 Coding standard considerations 5 Pros 6 Cons 7 A PHP coding standard 7 Formatting 8 PHP tags 8 Indenting 8 Line length 8 Line endings 8 Spacing 9 Statements 9 Strings 10 Arrays 11 Control structures 12 Class and method definitions 14 Naming conventions 14 Class names 14 Property and variable names 16 Constant names 17 Method and function names 17 Methodology 19 Type hinting 19 Separating object creation from initialization 19 Class files 20 Class names and directory structures 20 Visibility and access 21 Including source files 22 Comments 23 Inline documentation 23 Download from Wow! eBook www.WoweBook.com Table of Contents Coding standard adherence and verification 25 PHP_CodeSniffer for automated checking 25 Installing PHP_CodeSniffer 25 Basic usage 27 Slightly advanced usage 27 Validating against your own coding standard 29 Summary 38 Chapter 2: Documentation with phpDocumentor 39 Code-level documentation 40 Levels of detail 41 Introducing phpDocumentor 42 Installing phpDocumentor 42 DocBlocks 44 Short and long descriptions 44 Tags 44 DocBlock templates 45 Tutorials 46 Naming conventions and how to reference tutorials 47 DocBook syntax 48 Documenting a project 49 Documentation without DocBlocks 54 Documentation with DocBlocks 57 phpDocumentor options 67 Command line reference 67 Config files 69 Browser-based interface 70 Tag reference 71 Standard tags 71 Inline tags 83 PHP4 elements 91 Custom tags 92 Summary 92 Chapter 3: The Eclipse Integrated Development Environment 93 Why Eclipse? 94 Introducing PDT 96 Installing Eclipse 96 Requirements 96 Choosing a package 98 Adding the PDT plugin 99 Basic Eclipse concepts 100 Workspace 101 Views 102 Perspectives 104 [ ii ] Download from Wow! eBook www.WoweBook.com Table of Contents A PDT sample project 106 PDT features 109 Editor 109 Syntax highlighting 109 Code assist 110 Code folding 110 Mark occurrences 111 Override indicators 112 Type, method, and resource navigation 112 Inspection 114 Projects and files 114 PHP explorer 114 Type hierarchy 115 Debugging 115 PDT preferences 119 Appearance 119 Code style 119 Debug 120 Editor 121 New project layout 123 PHP executables 124 PHP interpreter 124 PHP manual 124 PHP servers 125 Templates 125 Other features 126 PHP function reference 126 Eclipse plugins 127 Zend Studio for Eclipse 129 Support 131 Refactoring 131 Code generation 131 PHPUnit testing 132 PhpDocumentor support 133 Zend Framework integration 133 Zend server integration 133 Summary 134 Chapter 4: Source Code and Version Control 135 Common use cases 136 A brief history of source code control 136 CVS 140 Introducing Subversion 142 Client installation 142 Server configuration 143 [ iii ] Download from Wow! eBook www.WoweBook.com Table of Contents Apache with mod_dav_svn 143 Subversion concepts 143 Repository 144 Tags 144 Trunk 144 Branches 145 Working (Local) copy 145 Merging 146 Revisions and versions 146 Updating 146 Comparing 146 History/Log 147 Annotating code 147 Reverting 148 Committing 148 Subversion command reference 148 svn 148 svnadmin 157 svnlook 158 svnserve 158 svndumpfilter 158 svnversion 158 Creating a Subversion project 159 Basic version control workflow 168 A closer look at the repository 172 Data store 172 Layout 173 Branching and merging 174 What is a branch? 175 Why branch? 175 How to branch? 176 Maintaining and merging a branch 177 Branching workflow 180 UI clients 182 Eclipse plug-ins 182 TortoiseSVN 185 WebSVN 185 Subversion conventions and best practices 189 Customizing Subversion 190 Hooks 190 Notifying developers of commits with a post-commit hook 194 Summary 195 [ iv ] Download from Wow! eBook www.WoweBook.com Table of Contents Chapter 5: Debugging 197 First line of defense: syntax check 197 Logging 199 Configuration options 200 Customizing and controlling config options: PhpIni 202 PhpIni example 208 Outputting debug information 209 Functions 209 echo(string $arg1 [, string $... ] / print(string $arg) 210 var_dump(mixed $expression [, mixed $expression [, $... ]]) and print_r(mixed $expression [, bool $return= false ]) 210 highlight_string(string str [, bool return]) and highlight_file(string filename [, bool return]) 212 get_class([object object]) 212 get_object_vars(object object) 212 get_class_methods(mixed class_name) 212 get_class_vars(string class_name) 212 debug_backtrace() 213 debug_print_backtrace() 213 exit([string status]) or exit (int status) 213 Magic constants 213 Writing our own debugging class 214 Functional

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    468 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us