Modifying extension to use homebrew PHP

Thank you for all your hard work on what I feel is an indispensable app!

I tried to “fix” the Sort extension by changing the path to php (homebrew) to /opt/homebrew/opt/php/sbin/php-fpm in the extension’s plist file.

Of course, the extension is altered and won’t install to PopClip for me to test. I tried running the following command in Monterey, even using sudo, quitting and restarting PopClip:

defaults write com.pilotmoon.popclip LoadUnsignedExtensions -bool YES

But, I was still unable to install this unsigned extension. Does this command no longer work in Monterey?

Thank you so much!


1 Like

Hi @elftyrrell, thanks for the kind words and welcome.

You are definitely on the right track. What you describe ought to work, both the PHP path change and the command to disable the unsigned extension warning (presuming that is the path to your PHP install of course :slight_smile:)

Let’s see if we can figure out what is going wrong.
What error message exactly are you seeing when you try to install your modified extension?

(As an aside, in the upcoming version of PopClip, v2021.11, you’ll be able to set the Script Interpreter value to just php and PopClip will locate it for you in your shell’s PATH.)

Hi Nick,

At first when double clicking on the extension, I received the php path error. I received this error again when I had the homebrew path incorrect (I left the -fpm at the end off). However, when I got the path correct (I think) I received the unsigned extension warning.

I’m guessing the path is now correct because there was no longer any warning about it.

I have run the terminal command above (defaults write com.pilotmoon.popclip LoadUnsignedExtensions -bool YES) and restarted PopClip. Yet, I still get this warning:

Maybe I should restart the system. I’ll try that although it shouldn’t make a difference, right? Thank you!


1 Like

Aha — what you need to do is change the Extension Identifier in your modified extension, to any string at all just as long as it doesn’t start with com.pilotmoon.. Then it should load no problem.

(To explain: PopClip will absolutely refuse to load unsigned extensions with that prefix, to prevent anyone impersonating the official extensions. I should probably make that error message more helpful!)

Btw I’m not sure about this php-fpm. I would’ve thought that the executable name would be just php. What do you get when you run the command which php ?.


Changing the Extension Modifier to something else worked!

I found the php executable installed by homebrew and copied the path: /opt/homebrew/Cellar/php/8.0.12/sbin/php-fpm into the plist.

I was not able to install the extension if the path left off the -fpm

However, using both of these paths to php:
/opt/homebrew/opt/php/sbin/php-fpm AND:

allowed the extension to install. Success??? Maybe …

When I tried to use the extension, all I got was an “x” which shook and the lines of text did not sort. In activity monitor, the php service is running and the path is correct.

I think the moral of the story is that Monterey removing php makes a mess of things and that you are absolutely taking the right approach to rewriting extensions using Javascript.

Maybe I’ll have a go at trying it myself if I have the time. Thank you for your help!


Haha - oh dear. Actually I suspect it might be that the version of PHP is too new. It looks like you are on the latest PHP 8, whereas the old extension was written for whatever shipped with macOS, which I think was v7.3. Perhaps it is throwing some exception.

Just did a quick test … I confirm it fails for me too with PHP 8.

But I tried

brew install php@7.3

And the set the interpreter path to


and then it worked for me on the Intel Mac I’m on right now.

On your M1 Mac I think it would be:



M1 and Monterey. This is causing issues. I am not able to install php 7.3 using homebrew:

“no bottle available!
You can try to install from source with:
brew install --build-from-source php@7.3
Please note building from source is unsupported. You will encounter build
failures with some formulae.”

Thank you for your help! I have an old iMac running Monterey and I’ll try php 7.3

I’m intrigued. Part of me wants to update the sort.php so it works with version 8. Part of me wants to dissect a Javascript extension to familiarize myself with the environment and make the Sort extension using Javascript code.


I like that thinking. The JavaScript dissection should be educational (in lieu of actual JS documentation… it’s coming I promise!). Although I should caution you that a lot of the GitHub sources (temporarily) either don’t reflect the final API or don’t tie up with the published popclipextz files, since I’ve been refining the JS API over the last few months to get it just right. But I’m pretty much happy with it now, and PopClip v2021.11 will be out next week. Everything should start to fall into place after that.

1 Like

Well, here’s the JavaScript I put together for Sort. It’s a nice easy one for seeing the structure of a simpler JS extension. (Will publish tomorrow.)


Thank you! I tried to make the existing php sort extension work with php 8, and thought maybe I might have cracked it. According to the documentation for implode() the delimiter string is the first argument and the array is the second. I swapped them but I still could not get it to work, lol :wink:

I’d really like to examine the new sort extension. I’d love to make my own in Javascript that alphabetically sorts a comma-separated list, e.g.

Seizure Disorder, Cerebral Palsy, Mitral Valve Prolapse, Thrombocytopenia, Hemorrhoids, Vitamin D Deficiency, Constipation, Onychogryphosis, Skin Cancer which required most of his left external ear to be resected.

Sorted to:

Cerebral Palsy, Constipation, Hemorrhoids, Mitral Valve Prolapse, Onychogryphosis, Seizure Disorder, Skin Cancer which required most of his left external ear to be resected, Thrombocytopenia, Vitamin D Deficiency.


1 Like

Oh please do! I need this all the time, several times I have almost gone and made one.

In fact thinking about it, there’s no reason this can’t be built into the sort extension itself….

I also want a “listify” extension that will convert a comma separated list to separate lines, and vice verse.

P.s. that list is making me feel grateful for my health