Book Image

Learning PHP 7

By : Antonio L Zapata (GBP)
Book Image

Learning PHP 7

By: Antonio L Zapata (GBP)

Overview of this book

PHP is a great language for building web applications. It is essentially a server-side scripting language that is also used for general purpose programming. PHP 7 is the latest version with a host of new features, and it provides major backwards-compatibility breaks. This book begins with the fundamentals of PHP programming by covering the basic concepts such as variables, functions, class, and objects. You will set up PHP server on your machine and learn to read and write procedural PHP code. After getting an understanding of OOP as a paradigm, you will execute MySQL queries on your database. Moving on, you will find out how to use MVC to create applications from scratch and add tests. Then, you will build REST APIs and perform behavioral tests on your applications. By the end of the book, you will have the skills required to read and write files, debug, test, and work with MySQL.
Table of Contents (17 chapters)
Learning PHP 7
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Integrating PHPUnit


Writing tests is a task that you could do by yourself; you just need to write code that throws exceptions when conditions are not met and then run the script any time you need. Luckily, other developers were not satisfied with this manual process, so they implemented tools to help us automate this process and get good feedback. The most used in PHP is PHPUnit. PHPUnit is a framework that provides a set of tools to write tests in an easier manner, gives us the ability to run tests automatically, and delivers useful feedback to the developer.

In order to use PHPUnit, traditionally, we installed it on our laptop. In doing so, we added the classes of the framework to include the path of PHP and also the executable to run the tests. This was less than ideal as we forced developers to install one more tool on their development machine. Nowadays, Composer (refer to Chapter 6, Adapting to MVC, in order to refresh your memory) helps us in including PHPUnit as a dependency of the...