There are a million PHP tutorials online. Most of these tutorials areoutdated and demonstrate obsolete practices. Unfortunately,these tutorials are still referenced today thanks to their Google immortality.Outdated information is dangerous to unaware PHP programmerswho unknowingly create slow and insecure PHP applications. I recognizedthis issue in 2013, and it is the primary reason I beganPHP The Right Way, a community initiative toprovide PHP programmers easy access to high-quality and up-to-date informationfrom authoritative members of the PHP community.
Youll hear me say community over and over (and over). The PHPcommunity is friendly and helpful and welcomingalthoughnot without occasional drama. If you become curious about a specific featurementioned in this book, reach out to your local PHP user group with questions.I guarantee you there are nearby PHP developers who would love to help youbecome a better PHP programmer. Your local PHP user group is an invaluable resource asyou continue to improve your PHP skills long after you finish this book.
What You Need to Know About This Book
Before we get started, I want to set a few expectations. First, it isimpossible for me to cover every way to use PHP. There isnt enoughtime. Instead, I will show you how I use PHP. Yes, this is anopinionated approach, but I use the very same practices and standardsadopted by many other PHP developers. What you take away from ourbrief conversation will be immediately applicable in your own projects.
Second, I assume you are familiar with variables, conditionals, loops,and so on; you dont have to know PHP,but you should at least bring a basic understanding of these fundamentalprogramming concepts. You can also bring coffee (I love coffee). Illsupply everything else.
Third, I do not assume you are using a specific operating system.However, my code examples are written for Linux. Bash commands areprovided for Ubuntu and CentOS and may also work on OS X. If youuse Windows, I highly recommend you spin up a Linux virtual machineso you can run the example code in this book.
How This Book Is Organized
demonstrates new PHP features like namespaces, generators,and traits. It introduces you to the modern PHP language, and it exposesyou to features you may not have known about until now.
explores good practices that you should implementin your PHP applications. Have you heard the term PSR, but youre notentirely sure what it is or how to use it? Do you want to learnhow to sanitize user input and use safe database queries? This chapter is for you.
is more technical than the first two parts. It demonstrateshow to deploy, tune, test, and profile PHP applications. We dive intodeployment strategies with Capistrano. We talk about testing toolslike PHPUnit and Travis CI. And we explore how to tune PHP so it performsas well as possible for your application.
provides step-by-step instructions for installing andconfiguring PHP-FPM on your machine.
explains how to build a local development environmentthat closely matches your production server. We explore Vagrant,Puppet, Chef, and alternative tools to help you get started quickly.
Conventions Used in This Book
The following typographical conventions are used in this book:
ItalicIndicates new terms, URLs, email addresses, filenames,and file extensions.
Constant width
Used for program listings, as well as within paragraphs to refer to programelements such as variable or function names, databases, data types, environmentvariables, statements, and keywords.
Constant width bold
Shows commands or other text that should be typed literally by the user.
Constant width italic
Shows text that should be replaced withuser-supplied values or by values determined by context.
Tip
This element signifies a tip or suggestion.
Note
This element signifies a general note.
Warning
This element indicates a warning or caution.
Using Code Examples
Supplemental material (code examples, exercises, etc.) is available fordownload at https://github.com/codeguy/modern-php.
This book is here to help you get your job done. In general, if example codeis offered with this book, you may use it in your programs and documentation.You do not need to contact us for permission unless youre reproducing asignificant portion of the code. For example, writing a program that usesseveral chunks of code from this book does not require permission. Sellingor distributing a CD-ROM of examples from OReilly books does require permission.Answering a question by citing this book and quoting example code does notrequire permission. Incorporating a significant amount of example code fromthis book into your products documentation does require permission.
We appreciate, but do not require, attribution. An attribution usually includesthe title, author, publisher, and ISBN. For example: Modern PHP byJosh Lockhart (OReilly). Copyright 2015 Josh Lockhart, 978-1-491-90501-2.
If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at .
Safari Books Online