Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:65538 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 20149 invoked from network); 31 Jan 2013 11:22:06 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Jan 2013 11:22:06 -0000 Authentication-Results: pb1.pair.com header.from=chrisw@aquacool.ltd.uk; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=chrisw@aquacool.ltd.uk; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain aquacool.ltd.uk designates 77.107.181.84 as permitted sender) X-PHP-List-Original-Sender: chrisw@aquacool.ltd.uk X-Host-Fingerprint: 77.107.181.84 stockport.aquacool.ltd.uk Received: from [77.107.181.84] ([77.107.181.84:38399] helo=stockport.aquacool.ltd.uk) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7E/74-09318-DD35A015 for ; Thu, 31 Jan 2013 06:22:06 -0500 Received: from DC01.aquacool.local ([fe80::9298:e041:a36d:d691]) by DC01.aquacool.local ([fe80::9298:e041:a36d:d691%11]) with mapi id 14.01.0438.000; Thu, 31 Jan 2013 11:22:01 +0000 To: "ivan.enderlin@hoa-project.net" , "internals@lists.php.net" Thread-Topic: [PHP-DEV] Proposal: php://memory/ (& ://temp/) Thread-Index: AQHN/5b4bRUOidzwGkuiKa+FajxFUZhjPBaQgAAI/oCAAAExgIAAAqgA Date: Thu, 31 Jan 2013 11:22:00 +0000 Message-ID: <075AE850888292488D400D9632DFE6E102400ACC@DC01.aquacool.local> References: <510A3B71.7060508@hoa-project.net> <075AE850888292488D400D9632DFE6E102400AA5@DC01.aquacool.local> <510A4FB7.2080107@hoa-project.net> In-Reply-To: <510A4FB7.2080107@hoa-project.net> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [192.168.63.150] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: RE: [PHP-DEV] Proposal: php://memory/ (& ://temp/) From: chrisw@aquacool.ltd.uk (Chris Wright) >On 31/01/13 12:00, Sebastian Krebs wrote: >> 2013/1/31 Chris Wright >> >>>> I propose the following syntax: >>>> >>>> php://memory/ >>>> php://temp//maxmemory: >>> I would very much like to see this as well. >>> >>> Would this also allow you to open multiple pointers to the same bucket? >>> >>> For example would this work? >>> >>> >> >>> $fp =3D fopen('php://memory/foo', 'w+'); >>> >>> file_put_contents('php://memory/foo', 'data'); >>> >>> rewind($fp); // would this be necessary? >>> >>> echo stream_get_contents($fp); // outputs 'data' >>> >> >> Everything else wouldn't make much sense, because why else should you=20 >> need to define an id for it? >> >> Bu whats about >> >> >> file_put_contents('php://memory/foo', 'data'); >> $fp =3D fopen('php://memory/foo', 'w+'); >> >> 'file_put_contents()' closes the stream after writing. I would expect,=20 >> that the engine will cleanup the memory (at least sooner or later),=20 >> but then I open it again. > Yup, I also expect the engine to clean memory when closing php://memory o= r php://temp, but this > is another proposal I think, no? >> Additional why don't you just pass the open stream around, if you need t= o >> access it at multiple places? > Is this question for me or Chris? If it is for me, I don't want multiple= =20 > accesses to the same "bucket"/space, I want multiple "buckets"/spaces. My thinking was for stuff like ZipArchive, which does not accept streams, o= nly paths. As it is there is no way to use ZipArchive entirely in memory, you have to write it = to disk (it also currently cannot cope with URLs so this alone would not fix it, but that's another st= ory). I admit the use case is narrow, but I do have a specific case where I need to post-process the r= esulting data before outputting/writing to the final file, this functionality would be a step to= wards working around this. I'm sure there are other examples of this as well. As ALeX pointed out, there are other ways to work in this manner using cust= om stream wrappers, and if it would be too difficult/wouldn't make sense to the engine to do this, the= n so be it :) Best Regards Chris Wright