AW: [PEAR-DEV] Re: [Proposal] Stream_Var
| From: | Stephan Schmidt | Date: | Fri, 15 Aug 2003 21:44:20 +0000 |
| Subject: | AW: [PEAR-DEV] Re: [Proposal] Stream_Var | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-19842@lists.php.net to get a copy of this message | ||
Hi,
At first, I did this to experiment with the new stream wrappers.
But I think it's usefull when developing an application that relies on
dirs and files that do not exists. You just build the structure in
memory and work with this structures like they were the directories and
files that the app will later use.
So I think it's something that will be used quite often when you are
debugging your application, as it's easier to fill an array than
creating a lot of directories if you do only need them for some miniutes
to test your application.
The question "Why not use the direct method" could be asked for other
stream wrappers as well, there's no need to use Stream_SHM, as you could
use the shm_* functions, but using stream wrappers adds a nice level of
data abstraction.
Stephan
> -----Ursprüngliche Nachricht-----
> Von: Greg Beaver [mailto:greg@chiaraquartet.net]
> Gesendet: Freitag, 15. August 2003 23:38
> An: schst@php-tools.net
> Cc: pear-dev@lists.php.net; gerd@php-tools.de; argh@php-tools.de
> Betreff: [PEAR-DEV] Re: [Proposal] Stream_Var
>
>
> Hi Stephan,
>
> I'm having a bit of difficulty imagining a reason I would use this
> instead of just accessing an array, can you provide a
> practical example,
> maybe the one that inspired you to write this, if there was anything?
>
> Greg
>
> Stephan Schmidt wrote:
> > Hi PEAR-Devs,
> >
> > I'd like to propose a new package called Stream_Var. This package
> > allows stream based access to variables using the stream
> wrappers that
> > have been introduced in PHP4.3.2
> >
> > That means you can do things like:
> >
> > $fp = fopen('var://GLOBALS/anyGlobalVar', 'r');
> >
> > and then use fread, fwrite, fseek, etc. on this filepointer to read
> > from and modify the variable. It supports GLOBALS, GET,
> POST, etc. If
> > 'anyGlobalVar' is an array, it behaves like a directory, that means
> > you could do the following:
> >
> > $fp = fopen('var://GLOBALS/anyGlobalVar/anyKey', 'r');
> >
> > of course with an unlimited depth :-)
> >
> > As arrays are directories, also the following is possible:
> >
> > $dir = opendir('var://GET');
> > while($entry = readdir($dir)) {
> > echo "$entry<br />";
> > }
> >
> > I still need to implement some minor things like different
> file modes
> > (r,r+,w,w+,a,...) and options so it's possible to trigger
> errors, that
> > give more detail, but the basic functionality is included.
> > @Greg: Yes, I know that I still have to include some inline
> > documentation, on which problem it does solve :-) I'll do
> that before
> > the first version is released.
> >
> > You can take a look at the sourcecode at:
> > http://www.php-tools.de/PEAR/Stream_Var/Var.phps
> >
> > Download it, with examples from:
> > http://www.php-tools.de/PEAR/Stream_Var/Stream_var.zip
> >
> > You can also take a look at the sourcecode of the examples at:
> >
> > http://www.php-tools.de/PEAR/Stream_Var/examples/example.phps
> > http://www.php-tools.de/PEAR/Stream_Var/examples/example2.phpsTžë�ŸëN
> > •ˆvjH PR
> >
> > The will not work on this server, as PHP4.3.2 is not
> installed :-( (I
> > already informed the hoster), but you can download the zip
> and test it
> > on your local machine.
> >
> > So please send your feedback and comments, so I can include this in
> > PEAR as soon as possible :-)
> >
> > Best regards,
> >
> > Stephan
> >
>
>
> --
> PEAR Development Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>