Book Image

Clean Code in PHP

By : Carsten Windler, Alexandre Daubois
5 (1)
Book Image

Clean Code in PHP

5 (1)
By: Carsten Windler, Alexandre Daubois

Overview of this book

PHP is a beginner-friendly language, but also one that is rife with complaints of bad code,;yet no clean code books are specific to PHP. Enter Clean Code in PHP. This book is a one-stop guide to learning the theory and best practices of clean code specific to real-world PHP app development environments. This PHP book is cleanly split to help you navigate through coding practices and theories to understand and adopt the nuances of the clean code paradigm. In addition to covering best practices, tooling for code quality, and PHP design patterns, this book also presents tips and techniques for working on large-scale PHP apps with a team and writing effective documentation for your PHP projects. By the end of this book, you’ll be able to write human-friendly PHP code, which will fuel your PHP career growth and set you apart from the competition.
Table of Contents (18 chapters)
1
Part 1 – Introducing Clean Code
8
Part 2 – Maintaining Code Quality

Conventions used

There are a number of text conventions used throughout this book.

Code in text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: “So, we will naturally create a service like UserRemover, which will perform these two tasks in a row.”

A block of code is set as follows:

<?php
class Example 
{
    public function doSomething() bool
    {
        return true;
    }
}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

{
  ...
  "scripts": {
      "analyse": [
          "tools/vendor/bin/php-cs-fixer fix src",
          "tools/vendor/bin/phpstan analyse --level 1 src"
        ],
        "post-update-cmd": "composer update -d tools",
        "post-install-cmd": "composer update -d tools"
    }
}

Any command-line input or output is written as follows:

$ php phploc src

Bold: Indicates a new term, an important word, or words that you see onscreen. For instance, words in menus or dialog boxes appear in bold. Here is an example: “Hovering the mouse pointer over TestClass will show a popup window with an explanation saying Undefined type TestClass.”

Tips or important notes

Appear like this.