Just try doing this way:
CURLOPT_RETURNTRANSFER=true curl --url localhost/mysite/file.php
(It’s works well for me)