Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:77981 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 49989 invoked from network); 14 Oct 2014 13:20:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Oct 2014 13:20:32 -0000 Authentication-Results: pb1.pair.com header.from=ben@benramsey.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=ben@benramsey.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain benramsey.com from 209.85.216.53 cause and error) X-PHP-List-Original-Sender: ben@benramsey.com X-Host-Fingerprint: 209.85.216.53 mail-qa0-f53.google.com Received: from [209.85.216.53] ([209.85.216.53:62300] helo=mail-qa0-f53.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6A/A4-26074-F132D345 for ; Tue, 14 Oct 2014 09:20:32 -0400 Received: by mail-qa0-f53.google.com with SMTP id v10so5724722qac.26 for ; Tue, 14 Oct 2014 06:20:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:content-type:mime-version:subject:from :in-reply-to:date:cc:content-transfer-encoding:message-id:references :to; bh=H2gjjZ/50YqIXNooK3wEILVlidumgppW04HYL4Fkt54=; b=P4tlynPbNBnnhWPJIZF+wiWRnk3Nr24/4yAytBoUdwzLYF++7jYnH39JfideiUxLRq j38Ucl10XwzqSNoSN7lKpv9AHYcAGss/jnUzI9NVCyuqVzCPnQ1s+VoYAEVh90Qsot0c 152ldK57v8GCgmdprSEY/8MNKGFqzBiwMwbKFSqDzOSnjh4NDJk9PVXx3ZwM6RzlqpT7 ukW8CC7e8GFXP/0fOLXZ0A9eWF63V1DMbhmWW+EiJFipCU77Rdu0QNAFwOCq9I0Tj04m oVt/wWI7cRmfNqu+mKZsAiI2kcCmtPXifBd2TNXnJSL2JnDKtauuVcE3PfOvXtO/CPYP pYdQ== X-Gm-Message-State: ALoCoQnk7xAKI9ZBWyAl0Mog5F/zJ2nZga+U/fCrFm3vJK4MIVsntl2uVhmO/vb2T8ITulJSvT6k X-Received: by 10.229.52.136 with SMTP id i8mr9333764qcg.6.1413292829615; Tue, 14 Oct 2014 06:20:29 -0700 (PDT) Received: from [10.0.0.70] (c-68-52-228-18.hsd1.tn.comcast.net. [68.52.228.18]) by mx.google.com with ESMTPSA id k4sm15865505qaf.0.2014.10.14.06.20.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 14 Oct 2014 06:20:29 -0700 (PDT) Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) In-Reply-To: Date: Tue, 14 Oct 2014 08:20:29 -0500 Cc: Andrea Faulds , PHP internals list Content-Transfer-Encoding: quoted-printable Message-ID: References: <776669CE-9E8C-4069-9834-C7275CCA0EF4@ajf.me> To: Kris Craig X-Mailer: Apple Mail (2.1878.6) Subject: Re: [PHP-DEV] New globals for PUT and DELETE From: ben@benramsey.com (Ben Ramsey) On Oct 14, 2014, at 8:09 AM, Kris Craig wrote: > On Tue, Oct 14, 2014 at 5:54 AM, Andrea Faulds wrote: >=20 >>=20 >> On 14 Oct 2014, at 13:47, Kris Craig wrote: >>=20 >>> Hey guys, >>>=20 >>> 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 = currently >> is >>> to parse their values by reading the incoming stream directly. >>>=20 >>> Is there a reason why we don't want this or is it just that nobody = has >>> actually written it yet? >>=20 >> $_GET and $_POST are really misnomers. $_GET is query string = parameters, >> $_POST is request body data. >>=20 >> We should just put the request bodies for all requests, not just = POST, >> into $_POST. >>=20 > The problem with that approach though is that it would not be RESTful. = I'm > developing a REST API (with the goal of 100% REST compliance) and = having > PUT/DELETE variables mixed in with $_POST would not only be > counter-intuitive, but it would just present a new roadblock. > Incorporating GET in there, as well, would make things even worse. >=20 > Basically, if we have $_GET and $_POST, then we should also have $_PUT = and > $_DELETE. Either that, or they should all be tossed. There's no = reason > why $_PUT and $_DELETE should not also exist. Putting everything into $_POST isn=92t a question of being RESTful or = not. REST in a Web application happens at the HTTP protocol level and not the PHP = level. That said, it would be confusing to place the request body for all = requests into $_POST. You also have to consider PATCH and the potential body for other HTTP = methods. The easiest way to get the body of any HTTP request is to use the input = stream: $requestBody =3D file_get_contents('php://input'); I suppose we could make a super global that returns that for us, but = it=92s just as easy to use the above. Additionally, you might not want to put the full body of = the request into memory like that. You might rather read the stream only a few bytes at a = time. -Ben