Recommend this page to a friend! | Stumble It! | Bookmark in del.icio.us |
All reviews | PHP Cookbook 3rd edition | Latest reviews | Best sellers ranking | |||||
TitlePHP Cookbook 3rd edition
CategoryPHP books
Authors
David Sklar
Adam Trachtenberg PublisherO'Reilly
Release dateJuly 25, 2014
ISBN144936375X
|
|||||||||||||||||||||||||||||
Reviews |
|||||||||||||||||||||||||||||
Jose GomezThis book covers the most of the important aspects of PHP programming such as its purposes, code readability, performance and different techniques that can be applied to software development. As the title "PHP cookbook" suggests, this is about PHP solutions in the form of recipes. It puts how to questions about PHP problems. Intermediate level developers can learn more efficient approaches than they usually may be using. Advanced developers can learn about important tips for the projects they are involved. "PHP Cookbook" has a well defined structure for each chapter: an introduction, on which readers can learn about a brief explanation about the subject, a set of recipes aiming to perform a task, the problem explanation, the proposed solution, discussion of the solution including problems to avoid, code readability, performance tips, documentation the reader can read to learn about the subject more in depth, and finally a sample program that integrates the most important concepts discussed in the chapter. The chapters can be grouped from general subjects and specific purposes. The first group consist of the first seven chapters. They explain the PHP basics, the concepts involved in PHP programming, starting from the most basic topics and continuing to increase the complexity. The first chapter explains all the important tips related to strings such us sub-string processing, trimming, field data record generation and parsing (fixed-width fields and CSV), line wrapping and binary data storage in strings. The second chapter focus in numbers. This chapter explains how to check if a variable stores a valid number, floating point numbers (how to compare and round them - important tips for numerical analysis and scientific developments), random number generation, basic mathematical functions, formatting, extensions for handling very large and very short numbers, bases converting and how the calculations are performed internally. The third chapter explains how to deal with date and time such us epoch timestamps, the importance of daylight saving and time zones, formatting, date and time comparison, validation and parsing from strings, get information for dates and time and a very curious topic, using different calendar types. The forth chapter is one of the most useful chapters of this part of the book. It explains the different techniques and functions for array handling from a performance point of view. It covers in detail the way arrays should be handled. Most of the times we work with arrays in not very efficient ways, even doing tasks by ourselves instead of using the existing functions. Reading this chapter, we will learn how to work with them. The fifth chapter covers the most important topics about variables such as dynamic variable names, persistence, sharing variables between processes using different techniques and complex data types encapsulation. Variable comparison is explained to avoid undesirable behavior. It can be also applied to other languages as C, C++ or Java. The sixth chapter covers almost everything about functions, from basic and well known topics to more advanced topics such as variable number of arguments, skipping return values, variable and dynamic function and something C and C++ programmers can missed for unknown returning values by reference. The seventh chapter explains classes and objects in the same order as other books but not talking about nomenclature directly. First the authors introduce the purpose of classes and then in the subject explanation they introduce the nomenclature. The reader can understand the utility of OOP easier starting from its purposes. Some concepts not present in other languages are very well explained, as their practical utility, like creating methods dynamically. The second group from chapter 8 to 19, covers the main purpose of PHP programming: Web development. Readers can find cool tips about preventing Web vulnerabilities among other things. The eighth chapter introduces the basics in Web programming in PHP, how to deal with cookies, requests, authentication, headers, status codes and send output to the browser. Chapter 9 explains how to process data input from form as well as how to validate them in order to prevent security vulnerabilities as cross site scripting and non desirable malicious data input. It also explains how to process input files and how to code in HTML pages groups of options to be processed in PHP scripts. Chapter 10 covers database access with PDO extension. The readers can find examples with Sqlite, MySQL and DBM databases. This chapter explains how to process data to be stored in databases as escaping quotes. In this chapter the authors mention NoSql databases and the extensions that need to be installed to work with them. Chapter 11 explains how to work with sessions and the their implications in data persistence, the ways the developer can prevent vulnerabilities, several ways sessions can be stored from security and performance point of view, as well several of their most used purposes. Chapter 12 covers the use of XML documents for data interchange in Web applications. It describes the different procedures for generating and parsing XML documents in PHP and handling content encoding and Xpath usage. It also explains how to deal with XSLT style sheets and XML documents validation. The basics of XML are intrinsically described and all the entities involved on XML. Chapter 13 explains how PHP can generate HTML code dynamically. It includes how to clean broken HTML code using the Tidy extension, get information from HTML pages such plain text and link, JavaScript integration using AJAX requests using jQuery returning JSON objects and XML documents. Chapters 14 and 15 covers RESTful APIs. For consuming them, authors explain how to access external URLs using socket streams, the Curl extension, HTTP2_Request class, and HTTP exchange debugging. For creating RESTful APIs, the authors explain how the request types will be used for each kind of access to RESTful APIs, data format used for data exchange, and how to use the HTTP errors in RESTful APIs. Chapter 16 explains how to access to different Internet services and the extensions needed for that. It covers email service (send emails using SMTP protocol and get emails using POP3 and IMAP protocols), FTP service (get and put files in ftp servers), LDAP services (LDAP basics are explained as examples for searching addresses and data with LDAP and how to use LDAP for user authentication), DNS service (get IP address, DNS lookups, domains information with WHOIS), ping service to check if a host is alive or down. Chapter 17 covers graphics handling using GD extension. The readers can learn how to draw graphics, graphic formats handling and get information from graphic files, how to serve images securely and creating thumbnails. I personally missed how to serve images using base64 encoding to put them in DOM documents. Chapter 18 covers security aspects of Web applications. This chapter explains the use of concepts described in previous chapters to avoid security vulnerabilities such session fixation, input filtering, cross-site scripting, SQL injection. This chapter also describes the way the developer should deal with passwords (storage practices, lost passwords, verifications, etc.) and how to share encrypted data between servers. There is a nice example how to send an encrypted email using GPG. I think in this chapter authors could have included a list of Web scanners to detect web vulnerabilities. Chapter 19 explains how to develop multilingual Web applications in PHP. It covers how to get user's locale, localizing texts (adapting texts to different grammars depending the language, formatting numbers, currency values, date and times), including files and file access, sorting text using the proper collation and manipulating UTF-8 text to include different encoding. The third group chapters from chapter 20 to chapter 23 is focused in code debugging and profiling. Although this group is focused in PHP development, it can be applied to other programming languages as well, using the proper tools and functionality. Chapter 20 covers error handling. It describes how to find, fix and prevent parser errors using information from error output and IDE for PHP, how to create and handle exceptions to prevent missing error handling in external extensions, and provide the proper error handling so other developers can use our own developments, how to use stack trace, reading and setting configuration variables, how to hide errors to users, write error handler and log errors and debugging information. Chapter 21 describes good practices in software engineering. It explains how to use Xdebug extension in PHP for proper code debugging in the same way other debugging software is used in other languages, how to use PHPUnit package for writing unit test in PHP and how to set up a test environment and use a built-in Web server. Chapter 22 describes how to tune up our developments. First important point is how to profile our code using functions for time measurement. Another important point is how to use Xdebug extension as a profiler and how to stress-test our Web site using Siege, ab and torture.pl tools. Perhaps the most important issue is when you use an accelerator, it can't solve our performance faults and do not avoid the problem of inefficient regular expression matching to cause a high overhead. This chapter also mentions Zend OPCache accelerator that is included in PHP 5.5, so code in PHP 5.5 is accelerated by default. Chapter 23 is a chapter that includes debugging and profiling techniques. It describes the right use of regular expressions and why ereg functions are deprecated in favor of Perl regular expressions. The next group of chapters are focused in command line PHP. Although files and directories can be used in Web applications, it is recommended to use databases in the Web environment. Use PHP as language for scripting requires the use of directories and files in PHP. Chapter 24 explains all the topics related with files such as opening and reading files, using temporary files, processing files (reading and creating CSV files as well INI files), reading from standard input and remote files, writing to standard output and flushing files. One important tip is about the way how to pass input and outputs to PHP scripts. This chapter mentions aspects of file handling functions that do not work in Windows environments. Chapter 25 explains the important topics about directories. It covers how to get information about files and directories in the file system, change permissions, the path differences between Windows and Unix systems. It also describes the way to deal with directories (make and remove directories). As in the previous chapter the functionality that is missing in Windows environments is also mentioned. Chapter 26 describes the tips regarding to the use of command-line PHP. It explains how to use command line arguments, how to use the same PHP script in command-line mode and Web mode, how to use getopt function and ncurses extension to read data from the keyboard, display messages and colorize output. The last group is really one chapter. Chapter 27 describes how to install, upgrade and uninstall Composer, PEAR and PECL packages. This is really a very good book for intermediate and advanced users. I missed a couple of tips like Web scanner references and a chapter describing Web services. Together with a reference guide it is the perfect tool for PHP developers because it covers the most important aspects and purposes of PHP development using a mini how-to recipes collection structure. These recipes consider performance, memory usage and code readability topics. It is a roadmap from the PHP basic concepts (strings, numbers, date and time, arrays, variables, functions and classes) to the main purposes of the PHP language like web programming (cookies, headers, sessions, forms, database access, RESTful APIs, XML documents, security and encryption, graphics, internet services and internationalization), extensiona and functions for debugging and profiling, file and directories handling, PHP usage from command-line and packages usages. This book enumerate tools, extensions and compilation options to access to the functionality recommended in the book.
|
|||||||||||||||||||||||||||||
CommentsNo comments were submitted yet. |