WordPress Plugin Development: Talking to APIs
curry-software.com
curry-software.com
However, to me it just highlights a lot of things that Wordpress/PHP is bad at. For one, no mention of testing here (or really hardly anywhere in PHP-land), although keeping the API logic in a separate class is a good idea.
Also, the flexibility/ease of use tradeoff going from wp_remote_get and friends is terrible. It's so frustrating that PHP doesn't have a better general networking solution than "idk, just fork to curl". The Guzzle library helps a lot here, but I don't see a lot of the PHP/WP community embracing it much.
With the current plethora of widely-supported Web development frameworks, I really don't see any reason to use PHP or Wordpress for new projects.
1. It's very easy to install for an inexperienced person, which is a pro shared by every PHP script you can imagine. If you're making a product meant to be run on shared hosting servers or aimed at a non technical audience, you do not want to have to say 'here's how to use the command line and here's how to set up SSH keys'.
2. So many other sites use it (especially news/blog sites) that using it makes things easier for new writers or other non technical people you want to contribute content to the service.
3. If you're part of a very small agency, aren't particularly interested in the programming side or want to get something done that can be done with a few plugins and a free theme and don't want to reinvent the wheel, it can work fine there too.
Yes, it's probably not recommended for those with significant software engineering/web development expertise, and there are certainly pain points for those in those situations, but I think the key thing to remember is that its ideal audience is a much less technical one with limited hosting options and a need for easy installation over code quality.
Plus, with the ability to create your own REST endpoints and pipe that into js, it's been pretty nice to work with. We've built some great data vizs with WP, Vue, SVGs...
I have a lot of reservations about Wordpress's hook-based architecture, and I get frustrated with old design decisions like the parameter order for `array_map` and `array_filter`, etc. etc. Sometimes you just need to vent.
Anyway, thanks for the perspective :)
I know my parent comment was pretty antagonistic, maybe we can both do better on that front in the future.
Agreed. The thought of using raw cURL in PHP to write an API service layer makes me shudder.
WordPress doesn’t use Guzzle because it requires PHP 5.2 compatibility. It does use an open source, third-party(-ish) library called Requests under the hood: http://requests.ryanmccue.info
(I maintain Requests, and am also a committer to WordPress.)
I'm a C++ dev, not a professional web developer, but I help out friends and family. With Wordpress I usually bill around 4 hours to do a website for someone if they have the content written.
I can turn a better site around that suits most peoples' needs in Jekyll these days in less time. I took the best of both worlds here and developed a workflow of: 1) private WordPress for content editing categorized content in Kramdown using only the ACF Pro and s3 uploader plugins 2) a process that builds and deploys a jekyll site to an HAproxy load-balanced NGINX cluster whenever anyone clicks Publish.
It pulls the content directly from the wordpress database at build time and the site uses webpack and whatever javascript niceties you'd expect from a site developed in 2018.
In a different life I had to maintain a website based on the Drupal CMS and also one based on the then-popular Laravel PHP framework, and in both environments testing was common and well-supported. As much as I dislike PHP, such a blanket statement does not hold up.
If you have to build the kind of site that needs to do the things that WordPress does, it's a great choice.
PHP, unfortunately, is never going to get away from the reputation that it earned and some of the choices it's stuck with, but it's a perfectly adequate language to develop web software with and the tooling these days is pretty good.
It's not my choice to use, but I'm happy to use it in a modern context.
In your experience, what are better web server languages and frameworks?
curl has the best (in general) performance and is the most robust, reliable, battle-tested connection library there is, full stop. And it's not just limited to HTTP.
Do I really want to take a gamble with my software stack against the millions of man hours that curl has been put through? I never understood the attitude people have against curl. Problems found are fixed quickly and way quicker than in anything else.
The only place where I have found this to not be true is in the Python community, for reasons I haven't quite understood yet.
curl handles high volume, is portable, is thread safe, has features no other competitor is approaching, supports IPv6, has a stable & mature API, is well documented. What more could you want from dependable software?