You are holding (now watching) in your hands the fourth, completely revised edition of a popular book. The previous edition was devoted to PHP 5 and was released 8 years ago. Since then, the language has been enriched with a large number of innovations, all of which we will highlight in the pages of the book. In this regard, the book had to be completely rewritten, only 10 chapters from 32 were based on the material of the previous book, although they had to be subjected to deep processing. The remaining chapters are written from scratch.
- Chapter 2. Installing PHP
- Chapter 3. Quick start
Object oriented approach
Before PHP 5, support for object-oriented programming (OOP) in the language was rather poor. In PHP 5, the object-oriented approach has long remained an alternative to the traditional procedural approach. PHP 7 is almost entirely designed for object-oriented development. Without OOP, the development of modern PHP applications is impossible: more and more extensions involve an object-oriented interface, components are designed as classes, PSR-standards and modern frameworks dictate a design that is completely oriented towards an object-oriented approach. That is why to get acquainted with the object-oriented approach, we begin immediately with the first chapters of the book. We consider design patterns and, where possible, focus on new extensions with an object-oriented interface.
PostgreSQL and Redis
Traditionally, PHP applications work in conjunction with MySQL. The rare PHP book does not focus on this popular database. However, we will depart from the tradition.
On the one hand, the resale of AB MySQL to Sun Corporation, which in turn was absorbed in 2009 by Oracle, led to the fact that the most popular free DBMS was in the hands of the world’s largest manufacturer of commercial databases. The development of MySQL, if not stagnant, is significantly inferior to competing databases, for example PostgreSQL, which for a long time remained on the sidelines.
On the other hand, the development of an object-oriented approach and an increase in the amount of memory on the servers led to a surge in interest in non-relational databases, which took the form of the NoSQL movement. PostgreSQL is not exactly a traditional DBMS. Conceived as an object-oriented database, PostgreSQL anticipated the SQL movement for several years. Therefore, today you can already see how most modern Web applications migrate to PostgreSQL.
In addition, instead of the traditional memcached, we consider the NoSQL Redis database. As a rule, modern Web applications cannot do without one or several NoSQL databases, so it is not possible to bypass them with attention. Redis stands out among them for its high performance (100,000 RPS-request per seconds), rich features (collections, clustering, PuL / Sub mechanism).
We do not consider a detailed installation of a full-fledged environment, including a Web server, setting up its connection with PHP, ensuring secure access to a remote server. Instead, use the built-in PHP server, immediately available when installing PHP.
Due to limitations on the volume of the book, it was necessary to abandon the description of many features of PHP, for example: detailed consideration of sockets, curl extensions, mathematical functions, image conversion, output buffer management, regular expressions and even file functions. All these possibilities are beyond the scope of the book.
Instead, each chapter is provided with tasks that encourage researching documentation, becoming familiar with functions and extensions not included in the book, researching alternative databases, reading articles, and searching for a solution. Only 100 tasks.
At the beginning of each chapter (with the exception of the 1st and 29th) there is a directory where you can find examples of this chapter, the file names are listed in the headings for the listings.
The source code for the book can be found on the GitHub account at:
Follow the link below to send questions to the authors:
The electronic archive with source codes for the book can also be downloaded from the link
ftp://ftp.bhv.ru/9785977538176.zip. This link is also available from the page of the book on the website www.bhv.ru.
Words of gratitude
We thank the authors Maxim Kuznetsov and Igor Simdyanov.
From Igor Simdyanov: “We wrote many books with Maxim Kuznetsov, and the first edition of this book was the start of our collaboration. Five years, as he is not with us: he lived quickly, brightly, helped many, it would seem, in desperate situations. This edition of the book is dedicated to him.”