A development environment is the set of tools you use to write and test code. For PHP you need four things.
1. A code editor
Use an editor that understands PHP. Visual Studio Code is free and has good PHP extensions. PhpStorm is a paid editor built for PHP. Either one underlines mistakes and completes function names, which saves a lot of time.
2. A way to run PHP
You can use Apache from a bundle like XAMPP, or the server that is already inside PHP. From the folder that holds your files, run:
php -S localhost:8000
Open http://localhost:8000/index.php in your browser. The built-in server is made for development only. Never use it for a public site.
3. Errors turned on
While you learn, you want PHP to tell you what went wrong. In your php.ini file, check these two settings:
display_errors = On
error_reporting = E_ALL
Only do this on your own machine. On a live site you turn display_errors off, which Production Error Handling explains.
4. A browser with developer tools
Press F12 in any modern browser. The Network tab shows every request your page made and the response PHP sent. It is the quickest way to see what PHP really returned.
Later additions
- Composer installs libraries. It has its own chapter: What Is Composer?
- Git keeps the history of your files.
- Xdebug is a debugger that can pause code line by line, covered in Debugging PHP Applications.