Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78832 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 94580 invoked from network); 7 Nov 2014 00:57:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Nov 2014 00:57:10 -0000 Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 192.64.116.216 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 192.64.116.216 imap10-3.ox.privateemail.com Received: from [192.64.116.216] ([192.64.116.216:35073] helo=imap10-3.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E6/01-24315-1E81C545 for ; Thu, 06 Nov 2014 19:57:07 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id 18F2E2400F7; Thu, 6 Nov 2014 19:57:03 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at imap10.ox.privateemail.com Received: from mail.privateemail.com ([127.0.0.1]) by localhost (imap10.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 9LDNfsUryrRF; Thu, 6 Nov 2014 19:57:02 -0500 (EST) Received: from oa-res-26-28.wireless.abdn.ac.uk (oa-res-26-28.wireless.abdn.ac.uk [137.50.26.28]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id 29E092400E8; Thu, 6 Nov 2014 19:57:00 -0500 (EST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.0 \(1990.1\)) In-Reply-To: <545C1823.8050404@sugarcrm.com> Date: Fri, 7 Nov 2014 00:56:58 +0000 Cc: Sherif Ramadan , Patrick ALLAERT , PHP Internals Content-Transfer-Encoding: quoted-printable Message-ID: References: <1DDB6E05-3143-4A74-8B13-AF85222579BA@ajf.me> <468730E8-4C38-49A3-A61A-59E107313D79@ajf.me> <545C1823.8050404@sugarcrm.com> To: Stas Malyshev X-Mailer: Apple Mail (2.1990.1) Subject: Re: [PHP-DEV] New Standardized HTTP Interface From: ajf@ajf.me (Andrea Faulds) > On 7 Nov 2014, at 00:53, Stas Malyshev wrote: >=20 > Hi! >=20 >> Again, I think you're oversimplifying the problem. For one, you don't = know >> that the payload is JSON unless you check the Content-type header = yourself, >> and you really shouldn't have to since PHP could easily do this for = you. >=20 > Sure, PHP could easily do this, or any other one specific use case for > you. What it can't do, however, is to do all 1000 use cases that = modern > REST application presents, automatically for you. What if you use XML > and not JSON? What if you use both and determine which one it is by > request URL suffix being .xml or .json? What if it instead is switched > by query parameter? What if also it can be compressed, encrypted and > wrapped in some MIME multipart message? Having all these complications > handled in the core of PHP would be extremely hard, not because each = of > them is hard, but because there can be so many of them. And you'd run = a > big change of PHP still not matching your specific case exactly, or > being behind times, because core can not evolve as quickly as userland > does. That's why it's better done in extensions or user space - unless > you can identify a case which covers a huge proportion of all cases - > just like forms are for POST. For generic REST, I'm not sure there's > such case, except for very generic API giving access to the basic > request, its fields and supporting basic URL/MIME parsing. Even just parsing JSON isn=E2=80=99t as simple as it sounds. There are = several things users might like to configure, several ways to parse JSON = (objects vs. arrays, big numbers as floats or strings, etc.), while for = form-data there=E2=80=99s only one way. -- Andrea Faulds http://ajf.me/