materix — 2012-05-23T17:49:05-04:00 — #1
I have two php applications that communicate with each other with a REST api, by using curl. Both applications are hosted on the same server.
My question is: Does it not give overhead to use curl for communication on the same server? Is it perhaps better to create a custom php function for this purpose?
michael_morris1 — 2012-05-23T18:03:00-04:00 — #2
k thanx buhbye.
b_rryp — 2012-05-24T05:54:27-04:00 — #3
Couldn't disagree with you more there.
Using include allows execution of code that is hosted remotely. If the file you're including from another server gets compromised, then you can consider this server compromised too. You're also relying on allow_url_include being set to on, which you shouldn't have on if you can avoid it.
Any kind of DNS attack could also expose include() to acquire a different remote file than the remote file you wanted.
fsockopen or curl would be your best bet. I don't think there's much between the two performance wise.
logic_earth — 2012-05-24T06:57:24-04:00 — #4
Its on the same server. Aka., file paths.
Besides, even if they were in different servers, you don't need URLs to share files between them.
michael_morris1 — 2012-05-24T07:17:52-04:00 — #5
Exactly - just copy the code you want to the second server in that event.
barry is right about remote file inclusion - very bad practice that. But that isn't what I was recommending. I was being a little snarky about it yesterday though so, meh.
Thing is, we are talking two applications. Likely referencing the same database. Writing a function to get the data shared should be trivial. If the two are using two different frameworks things get trickier. Since the OP is considering cURL for this problem my gut tells me he's outsmarting himself and making things way more complicated than they need to be. So Keep It Simple and Stupid. It will run faster that way.
b_rryp — 2012-05-24T07:37:36-04:00 — #6
Yep. Totally ignore me. I missed the "same server" bit.
include() will do the trick
If for any reason you do decide each application needs it's own server, then my response starts to make a bit more sense...