Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

As much as I know everyone dislikes PHP, there's lots of people still working with it. I love Requests in Python, so I built Requests for PHP: http://requests.ryanmccue.info/

I have to agree with Kenneth's points, in that pragmatism should outweigh the theoretical points. For example, in PHP, using a class as a grouping for static methods is a bad idea. I agree to a point, but there's something to be said for the ability to do `Requests::get('http://google.com/)` versus all the crap you have to do with cURL. (Plus, it's always >90% test coverage, which I stick to religiously.)



A little nitpick. In your tutorial you do:

    $request = Requests::get(...);
This should really be:

    $response = Requests::get(...);
As you get a Response object back.


Good point, thanks. I'll fix that up.


I think in the Python version they just use "r" so it's ambiguous.


I'll check this out. I use python at home but have to use PHP at work. Thanks :)


If autoloading namespaces or namespaced functions was possible then static classes wouldn't be needed and things like this would be commonplace:

    \Requests\get('http://google.com');


Another reminder of why in the fuck did they use the backslash character.


That's true, and it's something that's being discussed on the PHP core mailing list.

However, I support PHP 5.2 (pragmatic reasons; 5.2 is still used by a huge percentage of hosts), so I wouldn't be able to use that anyway.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: