Can we add a php page to discourse?

AFAIK you can not run PHP code in Ruby. There may be some kind of gem, but if there is, I don’t know of it.
On the other hand, Discourse should be able to work with non-Discourse JSON
You would need to smooth out same origin concerns, but I don’t see any reason why it couldn’t be done.