Setting Up WordPress Tutorial Environment
July 15, 2023
In some of my tutorials, we’ll work on one specific aspect of WordPress, and to do that, we need a testing environment. This tutorial will go over the setup I’m using for my tutorials, so you can set up your environment in the same way.
If you don’t need help setting up your local environment and just want to jump to how I’ve set up my tutorial environment, jump to Tutorial Setup. You can also find the code for this theme here on my GitHub. (Note, this excludes the change to wp-config.php. You can find information on enabling debug mode here.)
Jump To
- Local Hosting Tools
- Creating a WordPress Environment (Laragon)
- Finding Your Local Directory (Laragon)
- Other Versions of PHP (Laragon)
- Tutorial Setup
Local Hosting Tools
In order to work on WordPress on your computer, you’ll need to set host your site locally. For my tutorials, I’ve settled on Laragon. I have a Windows 11 machine, and I’ve tried XAMPP, Laragon, and Docker.
XAMPP works, but it’s difficult to swap between PHP versions. It also regularly crashes on my particular Windows 11 machine, which apparently happens to other users too. (If you have this happen, see this StackOverflow answer for how to fix it.)
I straight up couldn’t get Docker to work on my machine. Sometimes, running the same code a few times would produce different results. It would only let me load my local environment consistently on Firefox and not on Chrome. Code copied and pasted from official Docker tutorials would crash. After 8-10 hours of attempting various things over a week and a half, I decided Docker was just not going to cooperate.
Follow the instructions on the Laragon official site to download and install it.
You don’t need to be using Laragon; any working local environment is fine. However, I’ve provided some instructions specific to Laragon in this tutorial.
Creating a WordPress Environment (Laragon)
In Laragon, go to Menu > Quick app > WordPress
Choose a name for your project and click ‘OK’. (I will be using tutorial-wp as my project name.) A progress window will appear. On Windows, you may need allow the app to make changes to your device.
When the app has been created, you should see a window like this:
Click ‘Visit site’ to go to your new site. If you accidentally close, you can also reach your site by going to Menu > www > [Your Project Name].
You should see the WordPress install screen. Simply install WordPress as normal.
Finding Your Local Directory (Laragon)
We will need to add files to the local directory. This is the place Laragon will look for files related to your current project. You can find it by going to Menu > Explore > [Your Project Name].
If you’ve installed WordPress, you should see all the usual WordPress files and folders, including the wp-admin, wp-content, and wp-includes folders.
Other Versions of PHP (Laragon)
In any given tutorial, I will indicate what version of PHP we’re using. Use these instructions if you need to change PHP versions.
In Laragon, you can swap between versions of PHP by clicking Menu > PHP > Version [Your Current Version]. For example, my current setup looks like this:
If you’ve just installed Laragon, you’ll probably only have one version of PHP installed. To add more, go to the PHP Download Archives.
First, find the PHP release number. For example, let’s say you need PHP 7.4.3. Search for php-7.4.3 to find it.
You’ll see a whole bunch of options. Laragon likely installed the version of PHP that’s right for your PC, so I would suggest looking for the version that matches that format. For example, when I installed Laragon, it installed:
php-8-1-10-Win32-vs16-x64
I think this means “PHP version 8.1.10 for the Windows API (Win32) running on 64-bit architecture”. Regardless, I looked for the most similar PHP 7.4.3 version, which is php-7.4.3-Win32-vc15-x64.
Download the file for the version you need.
We need to find the PHP directory for Laragon. On my Windows 11 machine, it’s at C:\laragon\bin\php.
If you don’t find it there, open the PHP version menu in Laragon and choose the option with the folder icon that starts with dir. This will drop you into the folder for your currently active version of PHP. Go up in levels until you reach the PHP folder (which will just be called php).
Extract the zip file that contains the PHP version you downloaded into Laragon’s PHP folder. For example, mine looks like this:
If you go back to Laragon, you should now be able to switch between PHP versions by going to Menu > PHP > Version as in the first image above.
Tutorial Setup
Open your local directory for the current project. If you’re using Laragon, you can follow these instructions. Otherwise, if you’re having trouble look up a tutorial for the method you’re using to set up your local environment.
Turning on WordPress debug mode will display more information about certain errors. In your directory, look for a file called wp-config.php and open it in your text editor.
Search for this line:
define( 'WP_DEBUG', false );
Change false to true so the line becomes:
define( 'WP_DEBUG', true );
Save the file and close it.
We are going to create the most basic possible theme to use in our tutorials. To do this, go back to your project directory and go to wp-content > themes. You should see folders in there for each of the themes that come preinstalled with WordPress (for instance, you might see a folder named twentytwentythree and twentytwentytwo). Create a new folder labeled tutorial.
We’re just going to create the bare minimum to have a functioning theme. (Functioning as in ‘it will install without errors’.)
First, we’ll create a file that’s called index.php. Insert the following code into it:
<?php
phpinfo();
Now, we’ll create another file that’s called style.css. Insert the following code into it:
/*
Theme Name: Tutorial Theme
*/
And that’s it! Save these two files. This is going to create a theme that will do nothing but show the info about your current PHP version on any page. Not very useful, but it’ll be the springboard for other tutorials.
Log into the WordPress admin at [your-local-site]/wp-admin. Go to Appearance > Themes. You should see the Tutorial theme listed among the other themes.
Hover over the tutorial theme and click “Activate”. Visit the front end of your site and you should see information about the PHP version you’re currently using.
And that’s it! You can proceed with the rest of the tutorial.
Posted In: Tutorials






