Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78031 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 29066 invoked from network); 14 Oct 2014 16:22:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Oct 2014 16:22:14 -0000 Authentication-Results: pb1.pair.com header.from=florian@margaine.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=florian@margaine.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain margaine.com from 209.85.213.181 cause and error) X-PHP-List-Original-Sender: florian@margaine.com X-Host-Fingerprint: 209.85.213.181 mail-ig0-f181.google.com Received: from [209.85.213.181] ([209.85.213.181:53006] helo=mail-ig0-f181.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 94/99-18603-4BD4D345 for ; Tue, 14 Oct 2014 12:22:13 -0400 Received: by mail-ig0-f181.google.com with SMTP id r10so15234966igi.14 for ; Tue, 14 Oct 2014 09:22:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=XcopTsgJ4ZQ2C0eowvnGab9IqVWgk+dFlrjzo7g2IH0=; b=lealD7G3VQHXp4cpoRMpyC3I3t4bNp6SIotvNP7ElrpwxG6eG8wgWh5GI0AVvoSHg0 mbZ4vSf1kx4E3K/zaqtGBdxPNZ23Yrnz8lImgULJ3xgNxVKQ3j/y8AbnrCdOxQe/mBZ4 QlGBBzYcjhiJCcCa7WomATU8svdU91YFWlyQXU1SqcplSEoIY4NYiYI5Nxdk9SEKrquO LftJ91bKQOCdLVDdxpTqqsrrdmrrjOxw+aqy+BNHwbk5lWR0lMMVOE2oF6Zik1UsS/1o o8Y9g7ntdCGjG4mka9SZZ+J5njxgkru945bjDdpyHJ1LMdf4F1mP4j6Eu46gHUYcEtU0 dvZg== X-Gm-Message-State: ALoCoQlBqKbW9+aZBTiy4GUUJACYUAVpEKz31c+qLkRERMzQxNRut+L1N6k3wI8W9i9AjRc2T7BI X-Received: by 10.42.236.19 with SMTP id ki19mr3305006icb.73.1413303730115; Tue, 14 Oct 2014 09:22:10 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.25.133 with HTTP; Tue, 14 Oct 2014 09:21:49 -0700 (PDT) X-Originating-IP: [89.92.205.106] In-Reply-To: <543D4CE1.5000109@lerdorf.com> References: <776669CE-9E8C-4069-9834-C7275CCA0EF4@ajf.me> <8CB055D4-F164-4DF3-B019-684BAE7E016E@ajf.me> <543D47C1.9050009@lerdorf.com> <543D4CE1.5000109@lerdorf.com> Date: Tue, 14 Oct 2014 18:21:49 +0200 Message-ID: To: Rasmus Lerdorf Cc: Mike Dugan , Andrea Faulds , Kristopher , PHP internals list , Andrey Andreev , Kris Craig Content-Type: multipart/alternative; boundary=20cf302446adcb6d550505646a33 Subject: Re: [PHP-DEV] New globals for PUT and DELETE From: florian@margaine.com (Florian Margaine) --20cf302446adcb6d550505646a33 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi, If it were me, I'd rather delete all the superglobals. It's a horrible API, I don't think anyone can deny that. Now of course, it'd break a tons of code, so I don't suggest to actually delete it. However, instead of trying to work around current superglobals and trying to provide meaningful names, how about actually trying to provide a correct API? I won't suggest a Request class, because such an interface is best left to userland imho. However, I'd like to propose such an API: request_get(): gets a request array/object. It only has the unparsed request headers. request_cookie_parse(): parses the requests cookie header in an array similar to $_COOKIE. $_COOKIE could use this new function to build its array. request_cookie_get($name): gets the value of $name in the cookie. Calls request_cookie_parse() if it hasn't been called before. request_urlencoded_body_parse(): parses an urlencoded body. It'd give an array similar to $_POST. request_urlencoded_body_get($name): gets the value of $name in the parsed urlencoded body. Calls request_urlencoded_body_parse() if it hasn't been done before. request_query_string_parse(): parses the query strings of a request. It'd give an array similar to $_GET. request_query_string_get($name): gets the value of $name in the parsed query string. Calls request_query_string_parse() if it hasn't been called before. Basically, stop using the mess that superglobals currently are ($_REQUEST or $_SERVER), and start providing a sane, *very basic* API. The functionality remain the same, yet the API is actually sane. It allows userland to use this basic API and can easily build up on it. Maybe this is actually a non-issue and I'm thinking too much... just my $0.02. Regards, On Tue, Oct 14, 2014 at 6:18 PM, Rasmus Lerdorf wrote: > On 10/14/2014 09:15 AM, Mike Dugan wrote: > > On October 14, 2014 at 11:57:26 AM, Rasmus Lerdorf (rasmus@lerdorf.com > > ) wrote: > >> On 10/14/2014 06:29 AM, Andrea Faulds wrote: > >> > > >> > On 14 Oct 2014, at 14:27, Kristopher > wrote: > >> > > >> >> $_HTTP_REQUEST_BODY and $_HTTP_QUERY_STRING for nostalgia's sake. > >> > > >> > Ew, non-superglobals. > >> > > >> > But $_REQUEST_BODY and $_QUERY_STRING are a bit lengthy. Perhaps > $_QUERY (for $_GET) and $_BODY (for $_POST)? Then the variable set finall= y > makes sense, but isn=E2=80=99t too long: > >> > > >> > * $_QUERY - query string parameters > >> > * $_BODY - request body parameters > >> > * $_REQUEST - query string and request body parameters > >> > > >> > Makes more sense than $_GET and $_POST. > >> > > >> > Any objections? > >> > >> It makes no sense to me to make $_BODY an alias for $_POST. $_POST > >> implies the default body encoding that a broswer performs on a POST > >> request. Making an alias called $_BODY that doesn't contain the body o= f > >> a request unless it is "POST"-encoded would be super confusing. > >> > >> I think the pedantry level around this is rather high. Nobody is > >> actually confused about $_GET and $_POST and how and when to use them. > >> Adding vague aliases adds confusion to something that had no confusion > >> before. > >> > >> -Rasmus > >> > >> > > For clarity, $_BODY was revised to $_FORM. > > > > I think there was some misunderstanding of the usage of $_GET earlier i= n > > this thread, although I may have misunderstood someone=E2=80=99s wordin= g. > > Regardless, if I go out and sample 100 PHP folks, I=E2=80=99m fairly co= nfident > > someone would make the association that either $_GET or $_POST is bound > > strictly to the HTTP verb of the same name. Adding aliases gives these > > vars a more semantic name while not causing a massive BC breakage. > > I think 20+ years of history has proven this to be a non-issue. Of all > the things that people get confused by in PHP, $_GET/$_POST are right > near the bottom of the list. > > -Rasmus > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --=20 Florian Margaine --20cf302446adcb6d550505646a33--