The only thing that I can suggest is that any PHP file references must be an absolute URI reference. So it must exist in an external environment to run.
For example http://www.domain.com/form-action.php
i.e. <form action="http://www.domain.com/form-action.php" method="post">
If that does work in a Preview session then once you've verified that everything you want is working correctly, you can then return it back to a relative URI for export.
i.e. <form action="/form-action.php" method="post">
I believe @jo might know if something like this works, maybe?
Unfortunately I don't think I've added any PHP to any of my clients sites at this point, haven't needed it which is good since I don't do it LOL. That system does work for a lot of things though, so it's possible it may work for PHP items as well. Give it a try and see would be my suggestion. I do use that system mentioned by Saj for galleries and some other files such as PDF links and so on and I've had good luck with it so far.
It dawned on me that Preview, and probably Publish, are running on node servers, so there is no running LAMP server to serve up php. (?)
In my case I just wanted to test locally because uploading php files to a public server is a bit of a pain. So I can do as saj has suggested and hardcode "localhost/mybssTestSite/contact.php" while running my XAMPP server on my local PC.
Would be good if there was a FAQ page to provide this sort of advice, especially with regard to php because a contact form is pretty much standard on websites.
I ended up solving this by installing uWamp portable server and creating a virtual host for my bss project. Could probably have done the same with Xampp?