WordPress REST API with a Laravel Zero CLI and Tinkerwell

Today I decided to start work on a silly new thing.

It will involve CLI commands, so I went for Laravel Zero.

I needed to use the WordPress REST API. I figured someone must have written a Laravel HTTP client wrapper for this and Rick West delivered for me there!

But then I wanted to get Tinkering. And I reach for Tinkerwell (<- referral link) for that.

And that’s when the problems started. And I couldn’t find easy answers to any of these problems. So here they are:

“Target class [config] does not exist” error in Tinkerwell with Laravel Zero

I had this error appearing in Tinkerwell. I searched. I scoured. I even ChatGPT’d to no avail!

Eventually I realised that Laravel Zero needs its own Tinkerwell driver. And fortunately Owen Voke has provided that!

“cURL error 60: SSL certificate problem: unable to get local issuer certificate”

Of course, I’m working locally. I’m trying to use the WordPress REST API served from a local site running on Laravel Valet. And even though I’ve gone through the Valet certificate trusting dance, curl needs a little extra help.

My immediate thought was to reach for the 'verify' => false option. But could I find out how to set this?

Laravel provides Global Request Middleware, but this doesn’t let you set options. These can only be changed when creating an instance of the Http client.

And Rick’s wonderful WordPress API wrapper doesn’t let you set options.

SO… I hacked Http options into that and that works a treat.

I will PR this and hope that Rick accepts it.

In the meantime…

Laravel Zero with Tinkerwell and the WordPress REST API package!

Screenshot of the Tinkerwell tinkering app showing the use of Rick West's WordPress REST API package, complete with an API response! Yay!