Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:77979 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 48004 invoked from network); 14 Oct 2014 13:17:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Oct 2014 13:17:19 -0000 Authentication-Results: pb1.pair.com header.from=kris.craig@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=kris.craig@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.48 as permitted sender) X-PHP-List-Original-Sender: kris.craig@gmail.com X-Host-Fingerprint: 209.85.218.48 mail-oi0-f48.google.com Received: from [209.85.218.48] ([209.85.218.48:44054] helo=mail-oi0-f48.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CB/34-26074-E522D345 for ; Tue, 14 Oct 2014 09:17:19 -0400 Received: by mail-oi0-f48.google.com with SMTP id g201so16388091oib.21 for ; Tue, 14 Oct 2014 06:17:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=wRosurZz9ruQbco8E/HCM8VcA2jMLjVco+TJcv/Rnks=; b=dm/OZaNrOPtmo9e+93KnOa/sj0PVuF6Cq2cJHLkAZpRw2tVsHkvkxJIOd7hBvuwEFE pgL9qtlSx2cifuMSzZkEjlUZJ6Ndnv1CYNDwy2BSKuWw2LMv62joufJFpEIO610L5t/n 0haGo6hRtw0ISdXBIvD4C7iiKy/U0lvbm8OxOIvOcvp1I24OL+wY7A5Ge3m+9f5QxAl5 msWZgPrYslIMrLlG9/EV8zOXlt9PTBwi0uiwAfZQn8A1wC6UEENVKfQ18oOkuUgmmgne WjFHB+mazt2hO1ATKq+B/Ky619SnHVKQy2lHUvimWGlEE76oGExQ8CKpCMubsrS4xXzo Bc1A== MIME-Version: 1.0 X-Received: by 10.182.120.10 with SMTP id ky10mr637204obb.68.1413292636396; Tue, 14 Oct 2014 06:17:16 -0700 (PDT) Received: by 10.202.169.201 with HTTP; Tue, 14 Oct 2014 06:17:16 -0700 (PDT) In-Reply-To: <9CAD580B-48C1-4D91-B761-20F8A9804A66@benramsey.com> References: <9CAD580B-48C1-4D91-B761-20F8A9804A66@benramsey.com> Date: Tue, 14 Oct 2014 06:17:16 -0700 Message-ID: To: Ben Ramsey Cc: PHP internals list Content-Type: multipart/alternative; boundary=089e0139fc288e616e050561d533 Subject: Re: [PHP-DEV] New globals for PUT and DELETE From: kris.craig@gmail.com (Kris Craig) --089e0139fc288e616e050561d533 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Tue, Oct 14, 2014 at 6:09 AM, Ben Ramsey wrote: > On Oct 14, 2014, at 7:47 AM, Kris Craig wrote: > > > Hey guys, > > > > Does anybody know why we have $_GET and $_POST, but not $_PUT and > > $_DELETE? As far as I can tell, the only way to get these out currentl= y > is > > to parse their values by reading the incoming stream directly. > > > > Is there a reason why we don't want this or is it just that nobody has > > actually written it yet? > > > > =E2=80=94Kris > > This is due to the history of HTML forms sending POST requests with the > Content-Type application/x-www-form-urlencoded. That is, all the fields a= re > key/value pairs and may be easily converted into a PHP array. If you use > POST with application/json, nothing appears in $_POST, for example. > > In practice, we could support $_PUT and $_DELETE for requests that use > application/x-www-form-urlencoded, but most folks implementing PUT and > DELETE do not use application/x-www-form-urlencoded for these requests. > > I would venture to say that most people implementing PUT requests accept > application/json and most DELETE requests have no body at all. So, $_PUT > and $_DELETE superglobals wouldn=E2=80=99t make sense. > > -Ben > > I'm not following your logic, Ben. Just because there are a lot of people out there who don't understand REST, doesn't mean we shouldn't add support for the other methods. Besides, if anyone wants to develop a truly RESTful API in PHP-- which a lot of devs are doing every day-- not giving them $_PUT and $_DELETE is what wouldn't make any sense. I'm writing an API now and the lack of those two globals has proven to be a real pain in the ass. The Content-Type argument really isn't an issue since the API developer should be setting the right headers for the request method, anyway. I don't see any gain in not making those globals available. All it does is present both inconvenience and inconsistency for any REST-based project. --Kris --089e0139fc288e616e050561d533--