Live data from Hacker News

WordPress Plugin Development: Talking to APIs

curry-software.com

1–10 of 21 posts

Re: WordPress Plugin Development: Talking to APIs

#2
This is a really useful and informative writeup.

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.

Re: WordPress Plugin Development: Talking to APIs

#3

This is a really useful and informative writeup. 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 gen…

I think the reasons to still use WordPress and PHP at this point are really a mix of a few things:

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.

Re: WordPress Plugin Development: Talking to APIs

#4

This is a really useful and informative writeup. 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 gen…

With the posix extension, PHP does not have the capability to fork a process. And even if user is using curl, curl does not get forked. Do you know what the fork system call does? Do you think when you use curl, a process becomes forked?

Re: WordPress Plugin Development: Talking to APIs

#5
post #3

This is a really useful and informative writeup. 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 gen…

I think the reasons to still use WordPress and PHP at this point are really a mix of a few things: 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 k…

I wanted to add a number 4 to your list and that is the user experience to the client. I work in a digital agency and our main focus is on WordPress (after coming from the start-up world, this is sometimes painful for me). But, the ubiquity of WordPress and how consistent the software has been over the years, it is a no-brainer decision for clients.

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...

Re: WordPress Plugin Development: Talking to APIs

#6
post #4

This is a really useful and informative writeup. 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 gen…

With the posix extension, PHP does not have the capability to fork a process. And even if user is using curl, curl does not get forked. Do you know what the fork system call does? Do you think when you use curl, a process becomes forked?

‍️ well yeah, I guess my understanding was wrong, heh. Thanks for the pointer.

I know my parent comment was pretty antagonistic, maybe we can both do better on that front in the future.

Re: WordPress Plugin Development: Talking to APIs

#7
post #3

This is a really useful and informative writeup. 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 gen…

I think the reasons to still use WordPress and PHP at this point are really a mix of a few things: 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 k…

You're right, of course. I suppose I'm just frustrated that there isn't a similar widely-used solution available for non-technical folks that also doesn't feel painful for Web devs to extend.

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 :)

Re: WordPress Plugin Development: Talking to APIs

#8

This is a really useful and informative writeup. 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 gen…

>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.

Agreed. The thought of using raw cURL in PHP to write an API service layer makes me shudder.

Re: WordPress Plugin Development: Talking to APIs

#9

This is a really useful and informative writeup. 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 gen…

>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. Agreed. The thought of using raw cURL in PHP to write an API service layer makes me shudder.

The people who use the websites, really like wordpress. Nothing else is simpler and also does the job 99% of the time.

Re: WordPress Plugin Development: Talking to APIs

#10

This is a really useful and informative writeup. 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 gen…

Guzzle isn’t really embraced in the WP ecosystem for one main reason: WP has its own HTTP layer. It’s atypical for developers to switch out to using cURL, since the gains you get are fairly minimal, and you lose the benefits of the WP HTTP client. (Keep-alive connections aren’t particularly useful to most people.)

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.)

Post reply on HN