I use this code:
$this->curl = curl_init();
curl_setopt($this->curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
curl_setopt($this->curl, CURLOPT_TIMEOUT, 60);
curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->curl, CURLOPT_PROXY, '127.0.0.1:9050');
curl_setopt($this->curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($this->curl, CURLOPT_URL, "http://some-onion-site.onion");
$contents = curl_exec($this->curl);
It's returns nothing instantly. Tor is working normally, and site is accessible from tor browser. Edit: I've found that it can't resolve host ("Couldn't resolve host name" error).
Well, I've found out that I need to set proxy type to CURLPROXY_SOCKS5_HOSTNAME:
curl_setopt($ch, CURLOPT_PROXYTYPE, 7);
It works fine.