Software Engineering in WordPress, PHP, and Backend Development

Category: Tips (Page 1 of 10)

Various articles covering anything from how to programmatically achieve a certain task to useful ways that I’ve found to manage my time.

How To Remove Orphaned Domains from Laravel Valet

TL;DR: If you work with Laravel Valet and spin up new domains and then delete project directories whenever you’re done, Valet still maintains Nginx configurations on your system.

This create orphaned configuration files yielding false positives for active domains and this article demonstrates how to remove them.

Remove Orphaned Domains

Given the situation when you’ve updated Valet or refreshed your SSL certificates and restart the software, you may see a list of domains that you no longer have active on your system.

He’s so concerned about finding the orphaned domains. Also, he has two backpacks because he’s so productive.

That is, if you run $ valet links it yields a shorter list. So what are the orphaned domains and how do you remove them?

The orphaned domains are actually Nginx configurations, not directories or any references to projects. Since the domains are no longer active, we can remove them.

First, open your terminal and navigate to the Nginx directory:

$ ~/.config/valet/Nginx

Next, list all of the available configurations:

$ ls -l

For any configuration not listed in the $ valet links command, you can remove them by using the rm command. For example:

$ rm acme-domain.test

And that’s it. Remember you may need to repeat this whenever you remove a project that’s no longer linked.


One of the things that’s often brought to my attention is that people see the ERR_SPDY_PROTOCOL_ERROR whenever they try to access this site.


I’ve had people respond to links from my newsletter, from links on Twitter, from links from third-party sites, and sharing their experiences when trying to access other sites, too.

The thing is, few people – myself included – seemed to be able to diagnose the problem. (And believe me when I say that I’ve tried a ton of different things to fix it on my end.)

So to the best my ability, I researched the problem, all possible fixes, and thought I’d share what I found here along with the fixes.

Continue reading

Adjusting the First PhpStorm Breakpoint

Often, there are little idiosyncrasies that come with learning anything new. Thus, an IDE is no different.

And when it comes to learning a new IDE and how to use a debugger with it, there can often be small things that need to be adjusted or configured so that they help streamline your development.

For me, it comes with some of the default behavior of Xdebug. That is, if you’ve ever installed a new IDE and set it up to use Xdebug, you’ve likely experienced the behavior of having it start on the very first line of your web server or your application.

And this can be an annoying albeit preventable setting. If you’re using PhpStorm, here’s an easy way to fix it.

Continue reading

WordPress JSON Encoding For Ajax

If you’ve worked with Ajax in any capacity, then you’ve likely tried to send response data using various formats. Obviously, the original format of the response data is XML but JSON is a second, [and arguably] more popular format.

When working with WordPress’ Ajax API, arguably, the most important things to remember are:

  1. Make sure the function is using the proper hook (should it be available for the public, for users who are logged into their account, or both?),
  2. Terminate the function using wp_die unless you want an incorrect or malformed response sent to the client.

In addition to that, if you’re sending your response data to the client in the form of JSON then you have several options on how to return the data:

  1. Structure the JSON data yourself (which I think would be an overly complicated feat 🙂),
  2. Use PHP’s json_encode function,
  3. Or use WordPress’ wp_json_encode function.

You can see there this is going, right? So I’ll make it quick.

Continue reading

Quick Tip: Selecting a Line Number in Coda

One thing about the output the PHP CodeSniffer is it tells you the line number where your problem exists. This feature has obvious benefits – it lets you know exactly where you need to jump to fix the problem.

Our projects, though, are usually a wide set of files with a lot of functions and thus a lot of lines of code. If you’re proficient with your IDE, then it’s a trivial task to hop to the file and the line number.

But what if you’ve migrated to a new IDE or you’re not sure of the shortcuts that exist in your current IDE? That is, maybe you know how to click to find the feature, but using shortcuts is so much faster, isn’t it?

Continue reading

« Older posts

© 2024 Tom McFarlin

Theme by Anders NorenUp ↑