Last 2017, I have written an article on how to get you on the ground with test-driven development of TDD. In that article, I have laid down the foundation on how to get your development environment running with PHPUnit.

I am also in my early years doing test-driven development at that time and the unit testing I have discussed is actually integration tests because it hits your controller.

In this article, I will discuss the same PHPUnit principle but on package development.

Here is the final app: once you have finished the whole article.

1. Download the latest Laravel app.

Download the latest Laravel app and install it on your local machine (as of this writing, it is on Laravel 8). Then create a packages folder inside it.

The packages folder will be the location of all the packages that we will be developing.

2. Setting up your development environment

First, make sure your phpunit.xml is all good.

You can find this on: <laravel>/packages/simple-tdd-10-steps/phpunit.xml

This part is the most important:


Make sure that during testing, your database connection is set to sqlite and database is :memory: to run your tests faster.

3. Use the testing helper orchestra/testbench

In your composer.json file, add this

"require-dev": {
"phpunit/phpunit": "^8.5",



Jeff Simons Decena

Senior Fullstack Engineer, React Native developer and HL7 Health Informatics professional