So far, we’ve covered some things all of which lead us in setting up our local development environment. If you’ve not yet caught up, I recommend reading the previous articles:
- Local Development for the Indie WordPress Developer
- Databases and Tools for the Indie WordPress Developer
In the final article, I state the following:
Next, it’s time to get WordPress installed. It’s extremely easy, so if you’ve come this far, I’d state with confidence that the toughest part is over.
This is usually the easiest part (really), but there are two ways in which you can manage this, and I’m going to cover both. For those curious, it breaks down like this:
- installing the latest stable version of WordPress,
- installing the most recent nightly build of WordPress
There are reasons that you may want to use one versus the other. I tend to favor the latter when building out my own solutions for reasons I’ll cover later in the article but note that both of the above are covered in this post.
So with that said, let’s get started.
WordPress for Local Development
To be clear, when I refer to the latest stable version of WordPress versus the most recently night build of WordPress, I’m talking about two things:
- the version of WordPress you can download for free from WordPress.org right now,
- the version of WordPress you can checkout from the Subversion repository.
Depending on what you’re trying to achieve you may only need one instead of the other, but I find that using the version from Subversion is often a great way to make sure your code is both current and future-proof because it’s the latest snapshot of the code based on its current state of development.
But if you’re building something specifically for a certain version of WordPress, then perhaps using the latest stable version is fine.
Preparing to Install WordPress
Before downloading a version of the software, I always recommend setting up a directory into which you’re going to install the application and creating a database for it.
Depending on the nature of what you’re doing, you’ll likely be using source control (which is something I’ll cover later in this series of articles). But I’ve found it’s still nice to have it stored in a location where you can easily retrieve it should something happen to your machine.
Once that’s in place, it’s time to create the database. Since we’re using Laravel as our local development environment, then we know that the default top-level domain will be
.test and to that end, I like to have my databases follow that schema.
So, for example, I might have a domain called `wpdevtest` or `trunktest` depending on where I’m getting the code for the application. Regardless, to do this, you can use the command-line, PhpMyAdmin or your preferred database utility.
Mine is Sequel Pro, but the process is generally the same. You’ll need to refer to the documentation for how to do this within your software. After connecting to the server, simply opt to create a new database and name it whatever you’d like:
Simply put, you create an empty database and then the WordPress installation process will handle the rest.
A Note Before Installation
Where you opt to install the application, I recommend naming the directory that’s easy to recall and easy to type as you’ll be accessing it in your web browser using Valet. And Valet will use the name of the directory as part of the domain through which you access it.
Once you’ve created the database, the next steps are straightforward:
- download WordPress,
- unpack the archive into the directory of your choice,
- tell Valet where the application resides on your file system,
- walk through the installation process.
Downloading WordPress is easy as it’s accessible from this page and the huge Download WordPress button. Once it’s downloaded, simply unpack to the archive in the directory that you’ve created.
This can be in one of the aforementioned locations, or it can be somewhere else. The act of actually installing WordPress is easy, and I’ll cover that at the end of the post.
Downloading WordPress from Subversion
If you’re someone who would rather develop code against the most recent version of the codebase (that is, the one that has yet to be released and that’s still in development), you’ll need to checkout the code from the Subversion repository in which WordPress is stored.
For those who are new to source control, don’t panic. It’s really easy to do with applications that are made available to us (some free, some not). If you’re on Windows, checkout TortoiseSVN. If you use macOS, try Versions.
If you’re more experience, the command-line and these instructions may be your best bet.
Once you have your client of choice ready, you’ll need to provide a little bit of information. Each client offers the same fields but how it looks is a little different depending on your operating system.
The most important information that you need for a client is the address through which your client can checkout the WordPress codebase. That is as follows:
Most clients will let you browse the application on the server before downloading it. Note that when you do checkout the code, you’re going to want to check it out in the directory you’ve created.
I tend to use this method, so I check out the repository into a directory called
trunk. This way, I can continue to work on my own code (which are usually plugins) and then click on Update to pull the latest version of WordPress into the directory and evaluate my code against it.
The Installation Process
At this point, you should have two things:
- a database on which WordPress will run,
- WordPress downloaded and unpacked or checked out from a source code repository into a directory.
From here, it’s time to install WordPress. The software includes what’s called The Famous 5-Minute Installation (and it is quite easy), but there’s a few steps we need to take to prepare our development environment for this.
- we’re going to need to setup a domain via Valet and secure it,
- we’re going to need the host, the database username and password (as provided by Valet)
Luckily, all of the above is quite as easy. First, open a terminal and navigate to the directory in which you’ve installed WordPress. Next, enter the following command:
$ valet link && valet secure
This will set up a domain and an HTTPS certificate so you can access the WordPress installation (which we still need to setup). Let’s say, for example, you’ve just set up the installation to be accessible at
https://trunk.test. If that’s the case, point your browser to that location and start the installation process.
During the installation, you’re going to be asked a series of questions. The only two that may give you a problem are the ones about the database server, username, and password.
Since we’re using Valet, the respective fields are as follows:
- Server: localhost or 127.0.0.1
- Username: root
- Password: [leave it blank]
Assuming you’ve provided everything correctly, WordPress will complete its installation, and you’ll be presented with the home page or the login screen depending on which URL you aim to access.
Pre-Emptively Writing Safe Code
In the next set of posts, we’re going to look at tools and plugins that make it much easier to work with WordPress while writing code. That is, these tools will help you catch errors and problems in your code before you have to start debugging through proper tools like Xdebug.
Consider it a pre-emptive layer of protection before needing to do some real debugging work to ensure that you’ve done all you can to prepare for larger issues that you may have otherwise missed.