I have the same problem (see my recent post).
My solution was to place the php script in the moodle root directory. It works, but it is far from satisfactory (I don't know about security, but certainly for portability)
It would be probably possible to make it work from the repository, but then it should be called by its absolute address (not by file.php/etc) and any reference to moodle files should by hard-wired into the script, which IMO is worst that having it in the root.
I would be happy to read about a different solution
Piersante
Resource types
Cannot Display PHP file from resource repository
This discussion has been locked so you can no longer reply to it.