Re: [PHP4BETA] proposed fopen_wrappers generalization / patch v.2

From: Date: Thu, 08 Jun 2000 22:01:23 +0000
Subject: Re: [PHP4BETA] proposed fopen_wrappers generalization / patch v.2
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-16231@lists.php.net to get a copy of this message
Precedence: bulk Hello, While we are discussing this topic, has anybody thought of adding hooks to PHP to make it register stream handlers with user space classes? That would allow programmers that know PHP but not C, to develop new handlers for arbitrary types of streams that could eventually interface with external programs but for the users it would work like normal files. Programmers could develop new stream handlers without having to develop in C and not having to write an extension that needs to be compiled to be used. I can imagine a miriad of stream handler extensions been written in PHP and contributed by anybody. The way it could work is like this: - Have a function to register URL types with a given class. - When fopen() is called, a new instance of the class is created and the default constructor would be called. - There would be a standard set of methods and a metadata structure to let PHP figure what capabilities the stream handling class can implement, just to antecipate the evolution of the stream handling frame work and to provide emulation of features that may not be supported in the stream handler class. A nice capability that could be possible with this is to have stream handlers that act just as stream data filters, for instance to handle transparent compression, encryption, format conversion, etc.. I think this would be neat and most important it would be powerful without requiring users to learn a new set of STREAM API functions. What do you think? Here's an example: class https_stream_handler { var $metadata=array( "Support"=>array( "Write"=>1, "Read"=>0, "SeekForward"=>1, "SeekBackward"=>0 ) ); var $error=""; Function open($URL,$mode) { callCurl($url); } Function read(&$buffer,$length) { } Function seek($position) { } Function close($position) { } }; RegisterStreamHandler("https","https_stream_handler"); Regards, Manuel Lemos Web Programming Components using PHP Classes. Look at: http://phpclasses.UpperDesign.com/?user=mlemos@acm.org -- E-mail: mlemos@acm.org URL: http://www.mlemos.e-na.net/ PGP key: http://www.mlemos.e-na.net/ManuelLemos.pgp --

« previous php.version4 (#16231) next »