Test-Driven Development with PHP 8: Build extensible, reliable, and maintainable enterprise-level applications using TDD and BDD with PHP
- Length: 336 pages
- Edition: 1
- Language: English
- Publisher: Packt Publishing
- Publication Date: 2023-01-13
- ISBN-10: 1803230754
- ISBN-13: 9781803230757
- Sales Rank: #1169236 (See Top 100 Books)
A PHP developer’s practical guide to planning, writing, and deploying maintainable and extensible software solutions with automated tests in a well-structured way
Key Features:
Learn to organize and translate business requirements into maintainable software
Minimize regressions and bugs while releasing new features or bug fixes
Build maintainable applications using SOLID principles
Book Description:
PHP web developers end up building complex enterprise projects without prior experience in test-driven and behavior-driven development which results in software that’s complex and difficult to maintain. This step-by-step guide helps you manage the complexities of large-scale web applications. It takes you through the processes of working on a project, starting from understanding business requirements and translating them into actual maintainable software, to automated deployments.
You’ll learn how to break down business requirements into workable and actionable lists using Jira. Using those organized lists of business requirements, you’ll understand how to implement behavior-driven development (BDD) and test-driven development (TDD) to start writing maintainable PHP code. You’ll explore how to use the automated tests to help you stop introducing regressions to an application each time you release code by using continuous integration.
By the end of this book, you’ll have learned how to start a PHP project, break down the requirements, build test scenarios and automated tests, and write more testable and maintainable PHP code. By learning these processes, you’ll be able to develop more maintainable, and reliable enterprise PHP applications.
What You Will Learn:
Understand how to start a software project
Discover how to use Jira as a tool to organize your tasks
Explore when and how to write unit, integration, and functional tests using PHPUnit
Write behavior-driven tests using Behat
Apply SOLID principles to help you write more testable code
Get the most out of your automated tests by using continuous integration
Use continuous delivery to help you prepare your application for deployment
Who this book is for:
This book is for PHP software developers looking to implement TDD and BDD in their projects. An understanding of object-oriented programming is required to get the most out of this book. Professional software development experience will also be beneficial to understand real-life business cases.
Cover Title Page Copyright and Credits Foreword Contributors Table of Contents Preface Part 1 – Technical Background and Setup Chapter 1: What Is Test-Driven Development and Why Use It in PHP? What is TDD? Common misconceptions about TDD Testing software is not my job as a developer; therefore, I don’t need TDD Developing with TDD is unnecessarily slow Writing automated or unit tests is TDD TDD is a silver bullet Why should we even consider TDD? What are we planning to achieve in this book? Summary Chapter 2: Understanding and Organizing the Business Requirements of Our Project Technical requirements The example business project The business scenario Making sense of the scenario and the problem Breaking down the business requirements into software features Creating a Jira Cloud account and initializing the Jira Cloud project Creating a Jira epic Writing user stories Integrating Jira with Bitbucket Summary Chapter 3: Setting Up Our Development Environment Using Docker Containers Technical requirements Quick Setup What is a container? Setting up our PHP development container Creating multiple containers Running Docker containers Building a Docker image and running containers Stopping containers Summary Chapter 4: Using Object-Oriented Programming in PHP Technical requirements Understanding OOP in PHP What is OOP, anyway? Classes versus objects References and objects in PHP Abstraction in OOP Encapsulation in OOP Visibility in PHP Accessors and mutators Inheritance in OOP Polymorphism in OOP Polymorphism with a PHP abstract class Polymorphism with a PHP interface PHP Standards Recommendations (PSRs) What is a PSR? Summary Part 2 – Implementing Test-Driven Development in a PHP Project Chapter 5: Unit Testing Technical requirements Preparing the development environment for the chapter Defining unit tests Test coverage Declaring annotations Adding more functions to the solution class Using PHP’s reflection feature to directly test for private methods Indirectly testing for private methods Using shell scripts to run tests Types of tests Basket 1 – unit tests Basket 2 – integration tests Integration test example Installing Doctrine with Symfony Doctrine and database Failing our first integration test Creating a Doctrine entity Creating a Doctrine table for the entity Creating a test database Putting things together Why did we use an integration test in the first place? Summary Chapter 6: Applying Behavior-Driven Development Technical requirements Preparing the development environment for the chapter What is BDD? Applying BDD using Behat and Gherkin What is Behat? What is Gherkin? What is Mink? Installing Behat and Mink Writing PHP code based on Gherkin Browser emulators and Mink Why bother with Gherkin, then? Summary Chapter 7: Building Solution Code with BDD and TDD Technical requirements Preparing the development environment for the chapter Implementing the Red-Green-Refactor pattern Writing tests and solution code for the example project Creating a Behat feature based on a Jira ticket Creating a Behat registration feature Passing the Behat registration feature Writing failing controller tests Implementing a registration solution using Symfony Passing the Behat feature Summary Chapter 8: Using TDD with SOLID Principles Technical requirements Preparing the development environment for the chapter Jira to BDD to TDD Gherkin feature Behat context Functional test Integration test TDD with the Single-Responsibility Principle Writing the solution code TDD with the Open-Closed Principle TDD with the Liskov Substitution Principle TDD with the Interface Segregation Principle TDD with the Dependency Inversion Principle Summary Part 3 – Deployment Automation and Monitoring Chapter 9: Continuous Integration Technical requirements Preparing the development environment for this chapter Running and passing all the Symfony application tests Setting up the local environment Using Bitbucket Pipelines for CI Summary Chapter 10: Continuous Delivery Technical requirements Setting up an AWS EC2 instance Creating an AWS CodeDeploy application Installing Docker and other dependencies inside the AWS EC2 instance Connecting to the EC2 instance Installing CodeDeploy Agent Installing Docker Installing docker-compose Attaching Elastic IP to the EC2 instance Continuous delivery with Bitbucket Pipelines and AWS CodeDeploy Bitbucket Pipelines settings Creating a CodeDeploy configuration file Running Bitbucket Pipelines Summary Chapter 11: Monitoring Technical requirements Setting up New Relic APM for PHP Creating a New Relic account and license key Installing a New Relic agent in the PHP 8 container Going through the application performance data Monitoring other containers in your setup Summary Index Other Books You May Enjoy
Donate to keep this site alive
How to download source code?
1. Go to: https://github.com/PacktPublishing
2. In the Find a repository… box, search the book title: Test-Driven Development with PHP 8: Build extensible, reliable, and maintainable enterprise-level applications using TDD and BDD with PHP
, sometime you may not get the results, please search the main title.
3. Click the book title in the search results.
3. Click Code to download.
1. Disable the AdBlock plugin. Otherwise, you may not get any links.
2. Solve the CAPTCHA.
3. Click download link.
4. Lead to download server to download.