This is a Twilio Twimlet designed to be hosted on Heroku. It will query PagerDuty to find the currently on-call engineer and forward the inbound call to them.
It needs a few environment variables defined to work:
PAGERDUTY_SCHEDULE_ID PAGERDUTY_API_TOKEN PAGERDUTY_DOMAIN
Those names should be fairly self-explanatory. The domain is the piece of your PagerDuty URL that is specific to you i.e. https://[PAGERDUTY_DOMAIN].pagerduty.com/
You can also optionally set PHONEDUTY_ANNOUNCE_TIME, which if set to a TRUEish value will include the current time of the engineer being called as part of the answering message. This may help raise awareness that you are potentially getting somebody out of bed, so be gentle :D
Twilio TwiML reference https://www.twilio.com/docs/api/twiml
Some sample Twimlets: https://www.twilio.com/labs/twimlets
Setting up and deploying PHP apps on Heroku https://devcenter.heroku.com/articles/getting-started-with-php