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

This is exactly one of my points - and don't get me wrong - you're to blame here.

Let's dissect your post a bit: you had to google how to send GET/POST/PUT TO PHP or FROM PHP? Regardless, PHP doesn't care what you send it, you can send JSON or base64 encoded string. It's completely irrelevant. If you used PHP for 3 years and are unaware of basic HTTP communication - how's PHP to be at fault here? The real problem here is that you imagined something, it didn't work like you wanted it to and the next logical step is to blame the language. This is such a bad way of thinking, I genuinely feel sorry for you.

I could pull several projects that deal with input via HTTP in PHP, and they do it more than nicely. Issue is that you're simply - mediocre. And there's no language that can fix it. Btw. my intent is not to insult you, even a mediocre programmer can become a superstar.



I think most other languages and frameworks work via a more declarative API - "if a GET request to /this comes in, return that". I had to look it up / remind myself how it works in PHP as well the other day, and it's a bit more involved:

    - Create a .htaccess file that rewrites /api/x/y/z to /api/index.php/x/y/z
    - Read $_SERVER['PATH_INFO'] for the /x/y/z
    - Read $_SERVER['REQUEST_INFO'] for the HTTP method (GET/POST/etc)
    - Create the response starting with some calls to `header()`
    - 'echo json_encode($resp);'
I'm sure all that is abstracted away in e.g Laravel though. The PHP standard library could also do with an overhaul for modern applications for requirements like this though.


- $_SERVER contains server and execution environment info - $_REQUEST contains request input parameter values (regardless of http verb)

That's it. It's not a lot. They're 2 super simple arrays.

PHP can also work from command line where $_REQUEST/$_POST/$_GET are unavailable. You can also entirely ignore the existence of the above variables. You can read from standard input and treat input as JSON - options are endless. This merely means that the example shown is not entirely correct - it's not "how it works in PHP". It's merely one of the ways. But the real problem is: no one bothered to research it and you blindly assumed that's how it works.

Laravel (Http/Kernel library) standardized the interface towards the dev and that's great. But the input itself isn't as tied to PHP core as your comment makes it seem.




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

Search: