Re: [fw-general] idea - Zend_Encoder
-- Hector Virgen wrote (on Monday, 05 April 2010, 04:27 PM -0700): > This sounds like a really good idea! But I'm not too sure about the namespace > "Encode". Do you think there might be more opportunities for two-way > transformation besides just encoding? I'm thinking gzip/deflate, encrypt/ > decrypt, etc. Please don't forget that We _do_ already have Filters for encryption and compression, as well as Zend_Crypt; let's not re-invent the wheels we've already built. :) Also, based on the description here, I would argue that the primary functionality already exists and can be accomplished in Zend_Filter. The only areas I see as being potenentially new would be URL and Base64 encoding - and these could be added to Zend_Filter easily. As an example: // Encryption $filter = new Zend_Filter(); $filter->addFilter(new Zend_Filter_Encrypt(array('adapter' => 'base64'))) ->addFilter(new Zend_Filter_Encrypt(array('adapter' => 'urlencode'))); $encrypted = $filter->filter($someValue); // Decryption $filter = new Zend_Filter(); $filter->addFilter(new Zend_Filter_Decrypt(array('adapter' => 'urlencode'))) ->addFilter(new Zend_Filter_Decrypt(array('adapter' => 'base64'))); $decrypted = $filter->filter($encrypted); The API is slightly different than what is presented here, but the results would be the same. > On Fri, Apr 2, 2010 at 2:17 PM, OnyxRaven wrote: > > > I've been doing some work with some of the symmetric Filters - especially > encryption and urlencoding. What I've come up with is a more 'formal' > class > which encompasses and encoder and a decoder. > > The idea is that the same Zend_Encoder based class should be just an > identity to the value passed in. > > (given scalar $x, $params to Crypt;) > $enc = new Zend_Encoder_Crypt($params); > $y1 = $enc->encode($x); > $y2 = $enc->decode($y1); > assert($x === $y); > > An Encoder could easily be just a composition of Filter objects. > > Encoder chaining would run encode() in the order specified in the chain, > but > decode() would run in reverse order. > > $enc->addEncoder(Zend_Encoder_Base64) > $enc->addEncoder(Zend_Encoder_UrlEncode); > $enc->encode(); // runs Base64->encode(); UrlEncode->encode(); > $enc->decode(); // runs UrlEncode->decode(); Base64->decode(); > > Is this a valuable class? If so, I'll happily put together the proposal > and > start up some basic implementations. > -- > View this message in context: http://n4.nabble.com/ > idea-Zend-Encoder-tp1749646p1749646.html > Sent from the Zend Framework mailing list archive at Nabble.com. > > -- Matthew Weier O'Phinney Project Lead| matt...@zend.com Zend Framework | http://framework.zend.com/ PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc
Re: [fw-general] idea - Zend_Encoder
Yeah, I tried to come up with something else - Codec was one - but really, gzip, crypt, etc are special cases of encoding. I don't know, if anyone can come up with a good alternative I'm open to ideas there. On Mon, Apr 5, 2010 at 5:27 PM, Hector Virgen wrote: > This sounds like a really good idea! But I'm not too sure about the > namespace "Encode". Do you think there might be more opportunities for > two-way transformation besides just encoding? I'm thinking gzip/deflate, > encrypt/decrypt, etc. > > -- > Hector > > > On Fri, Apr 2, 2010 at 2:17 PM, OnyxRaven wrote: > >> >> I've been doing some work with some of the symmetric Filters - especially >> encryption and urlencoding. What I've come up with is a more 'formal' >> class >> which encompasses and encoder and a decoder. >> >> The idea is that the same Zend_Encoder based class should be just an >> identity to the value passed in. >> >> (given scalar $x, $params to Crypt;) >> $enc = new Zend_Encoder_Crypt($params); >> $y1 = $enc->encode($x); >> $y2 = $enc->decode($y1); >> assert($x === $y); >> >> An Encoder could easily be just a composition of Filter objects. >> >> Encoder chaining would run encode() in the order specified in the chain, >> but >> decode() would run in reverse order. >> >> $enc->addEncoder(Zend_Encoder_Base64) >> $enc->addEncoder(Zend_Encoder_UrlEncode); >> $enc->encode(); // runs Base64->encode(); UrlEncode->encode(); >> $enc->decode(); // runs UrlEncode->decode(); Base64->decode(); >> >> Is this a valuable class? If so, I'll happily put together the proposal >> and >> start up some basic implementations. >> -- >> View this message in context: >> http://n4.nabble.com/idea-Zend-Encoder-tp1749646p1749646.html >> Sent from the Zend Framework mailing list archive at Nabble.com. >> > >
Re: [fw-general] idea - Zend_Encoder
This sounds like a really good idea! But I'm not too sure about the namespace "Encode". Do you think there might be more opportunities for two-way transformation besides just encoding? I'm thinking gzip/deflate, encrypt/decrypt, etc. -- Hector On Fri, Apr 2, 2010 at 2:17 PM, OnyxRaven wrote: > > I've been doing some work with some of the symmetric Filters - especially > encryption and urlencoding. What I've come up with is a more 'formal' > class > which encompasses and encoder and a decoder. > > The idea is that the same Zend_Encoder based class should be just an > identity to the value passed in. > > (given scalar $x, $params to Crypt;) > $enc = new Zend_Encoder_Crypt($params); > $y1 = $enc->encode($x); > $y2 = $enc->decode($y1); > assert($x === $y); > > An Encoder could easily be just a composition of Filter objects. > > Encoder chaining would run encode() in the order specified in the chain, > but > decode() would run in reverse order. > > $enc->addEncoder(Zend_Encoder_Base64) > $enc->addEncoder(Zend_Encoder_UrlEncode); > $enc->encode(); // runs Base64->encode(); UrlEncode->encode(); > $enc->decode(); // runs UrlEncode->decode(); Base64->decode(); > > Is this a valuable class? If so, I'll happily put together the proposal > and > start up some basic implementations. > -- > View this message in context: > http://n4.nabble.com/idea-Zend-Encoder-tp1749646p1749646.html > Sent from the Zend Framework mailing list archive at Nabble.com. >