PHP 7 Programming in Practice cover

PHP 7 Programming in Practice

No rating yet
Chapters
1
Series
PHP 7 Programming Cookbook
ISBN
9787121327728

Tags

Summary

PHP 7 Programming Cookbook is a hands-on PHP 7 technical book by the veteran American software developer Doug Bierer, translated into Chinese by Su Baolong. The Chinese edition was published by Publishing House of Electronics Industry in 2017; the original is PHP 7 Programming Cookbook, with simplified Chinese rights granted by Packt Publishing. The book has 13 chapters plus an appendix and is organized as practical recipes in a problem–solution–discussion format, moving by topic from setting up an environment all the way to engineering practice. Chapter 1 covers installation and configuration notes for PHP 7, the built-in web server, a MySQL database for testing, installing PHPUnit and class autoloading, and completes a website scanner and a PHP 5 to PHP 7 code converter. Chapter 2 explains abstract syntax trees, parsing and foreach handling differences, performance enhancements, traversing large files, importing spreadsheets into a database and a recursive directory iterator. Chapters 3 and 4 cover functional programming (type hints, return type declarations, iterators and generators) and object-oriented programming (inheritance, static members, namespaces, visibility, interfaces, traits, anonymous classes). Chapters 5 to 7 focus on database interaction (PDO, an OOP-style SQL builder, pagination, entity mapping, secondary queries, jQuery DataTables queries), a form-element generator and form factory for scalable websites, $_POST filtering and validation, and XML conversion, REST and SOAP clients and servers. Chapters 8 to 10 discuss date/time and internationalization (handling emoji, character conversion, locale detection, number and currency formatting, internationalized calendars and recurring events, non-gettext translation), middleware (validation, access control, caching, routing, cross-framework and cross-language calls) and advanced algorithms (linked lists, bubble sort, stacks, binary search, search engines, multidimensional array aggregation). Chapters 11 to 13 move into engineering: design patterns such as hydrators, the strategy pattern, mappers, object-relational mapping and publish/subscribe; $_POST data filtering and validation, session protection, tokens and CAPTCHAs, a password generator, and encryption/decryption without mcrypt; best practices, exceptions and error handling, unit tests and test suites, mock data generation and custom session parameters. The appendix implements PSR-7 value objects, request classes and response classes in detail.

Editor's review

很多 PHP 7 入门书停留在语法罗列,这本书胜在“配方式”实战:13 章全部围绕可运行的任务展开,从安装环境、PHPUnit 与自动加载起步,一步步写到中间件、PSR-7、加密与单元测试。作者 Doug Bierer 有三十余年开发经验,书中示例既有工具性(网站扫描器、代码转换器、SQL 生成器、表单工厂、数据水合器),也有方法论(策略模式、映射器、发布/订阅、对象关联映射),读者照着做就能把碎片知识串成完整工程能力。第 8 章的国际化日历与循环事件、第 9 章的跨框架跨语言中间件、第 12 章的验证码与不依赖 mcrypt 的加密解密,在同类书中并不常见,对维护老项目、准备迁移到现代 PHP 框架的开发者尤其有参考价值。需要提醒的是,书中部分 API(如 mcrypt 扩展、旧版 PSR 实现路径)在今天已发生变化,阅读时应结合当前 PHP 版本官方文档对照,把重点放在设计思路而非逐字照抄代码上。整体而言,这是一本适合当作“案头工具书+进阶路线图”反复翻查的中高级读物。

Who it's for

A good fit for

  • 已掌握 PHP 基础语法、希望系统进阶到中高级水平的开发者
  • 需要维护或迁移旧版 PHP 项目、关注 PHP 5 到 PHP 7 差异的技术人员
  • 想补齐 PSR 规范、中间件、设计模式与单元测试认知的后端工程师
  • 软件架构师与技术主管,可作为团队技术规范与代码审查的参考读本

Not a good fit for

  • 完全没有编程经验的零基础读者,书中不铺垫变量、循环等入门概念
  • 只想学某一个现成框架快速做出网站、无意理解底层设计的读者
  • 希望获取最新 PHP 8 及以上版本特性的读者,本书内容以 PHP 7 为基准

Reading tips

  1. 建议边读边搭环境:先按第 1 章装好 PHP 7、MySQL 与 PHPUnit,后续每章示例都在自己机器上跑通。
  2. 不必从第 1 章顺读到底,可按工作需求跳跃阅读,例如先攻第 5、6 章数据库与表单,再回头补第 9、11 章。
  3. 遇到 mcrypt、旧版 PSR-7 示例等已过时的写法,先查当前 PHP 官方文档,理解思路后再动手改写。
  4. 把第 10、11、13 章当作练习册,尝试用手头项目复写链表、策略模式与单元测试,效果远胜只读代码。

About the publisher

Publishing House of Electronics Industry China · Founded in 1982

The Publishing House of Electronics Industry is a comprehensive publisher distinguished by its focus on electronic information and related fields. Judging from the more than 3,000 titles in its catalogue, its publishing covers programming and design, artificial intelligence, computer science, finance and economics, photography, and social sciences, attending both to cutting-edge technology and to general readers. Representative titles include Factor Investing: Methods and Practice, x86 Assembly Language: From Real Mode to Protected Mode, The RISC-V Reader, Artificial Intelligence: Speech Recognition, Understanding and Practice, Phased Array Radar Technology, Radar Target Characteristics, and 100 Go Mistakes and How to Avoid Them, most of which centre on technical methods and engineering practice. Its authors include Shi Chuan, Li Zhong, Wang Xiaobo, David Patterson, Andrew Waterman, and Yu Zihao, among others from China and abroad. Owing to limited public information, no further publishing features are elaborated here.

Contents

  1. Boyan Vision

FAQ

这本书适合 PHP 初学者吗?
不太适合。书中默认读者已掌握 PHP 基础语法,直接进入命名空间、trait、PDO、中间件与设计模式等中高级主题,零基础读者会感到吃力,建议先补一本 PHP 入门教程再读。
原书名是什么?中文版是哪家出版社出的?
原书为 Packt Publishing 出版的《PHP 7 Programming Cookbook》,简体中文版由苏宝龙翻译,电子工业出版社 2017 年 10 月出版,属于“博文视点”系列,ISBN 为 978-7-121-32772-8。
书里的代码现在还能直接运行吗?
大部分核心示例仍可参考,但涉及 mcrypt 加密扩展、部分 PSR-7 实现和旧版依赖的代码已随 PHP 版本演进失效,建议在 PHP 7 环境验证思路,再按当前官方文档改写。
全书共多少章,主要覆盖哪些内容?
正文 13 章加一个附录,涵盖环境与工具、PHP 7 高效特性、函数式与面向对象编程、数据库交互、表单与可伸缩网站、REST/SOAP Web 服务、国际化、中间件、高级算法、设计模式、网页安全、最佳实践与测试调试,附录实现 PSR-7 相关类。

Comments

Find this book

This site is an index: you start “Search all sources” in your browser, and the entries it lists all point to third-party sites; please judge their availability yourself.

More by the same author

Top rated in the same category