How to create php REST API in Gateway?

Hi Everyone,

I have one scenario where i need to use php script which has a REST API implementation and i need to run that php file on API Gateway, so that i can access the endpoint in webcomponent.
is it possible?

Can you elaborate on exactly what this means? That the php is making calls to some API? That the php accepts calls in some way, being an API provider?

Short-answer: not going to be able to run/host the php script in API GW.

Hi @reamon,

Thankyou for your response. yes php script that accepts a call being an API provider. if not in API GW then is there any way we can add it in IS(integration server) like we do in htdocs for apache server to run php

You PHP file runs in a webserver?
Is the PHP facilitating an API or a HTTP endpoint that you call with some parameters or body?

You can create an AP manually I in the gateway that can proxy the php end point and apply policies/etc.

Hi @Dave_Pemberton,
No my php file is not hosted on webserver, we want to host it on web methods Integration server if possible. something like this
https://localhost:5555/widget.php

Is there any public directory to add files in IS?

Integration server OOTB (also API Gateway) can not execute/run PHP files.

You’d have to install a PHP ready webserver (e.g. Apache/lighttpd, mod_php, etc) on a server which could serve the php file, or you could run the php file from the command line (depending on the php file).

If the PHP file is in a webserver, then you can directly link it in the gateway assuming it’s reachable from the gateway end point, and/or also use the httpclient in IS to invoke it.

If it’s a command line type PHP, you could use IS to invoke the PHP file from the command line my making a shell/command invocation.

2 Likes

One more point - you can add files in IS into your package’s pub directory, which are served, but this won’t support PHP, only static files (e.g. HTML/etc) or the webMethods DSP file format, which I tend to prefer not to use now, rather I’d create a REST API based service in IS, and have a HTML in the pub directory that consumes this via a javascript XMLHttpRequest call.

Thankyou @Dave_Pemberton for your help. It is more clear to me now.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.