[fw-general] Problem with ZF2 exceptions and SPL exception inheritance
I've been looking at the ZF2 exception proposal and trying to wrap my head around all the use cases involved in it. For the most part, it makes perfect sense, except when a component wants to have exceptions classes for two SPL exceptions and one of those SPL exceptions extends the other. Since you have to extend the SPL exception in both cases, the child component exception class cannot extend the parent component exception class. The end result is that you cannot catch the parent component exception class and expect the catch the child component exception class. I don't think I did a very good job explaining the issue, so here's an example: \Zend\Search\Lucene\Exception\RuntimeException and \Zend\Search\Lucene\Exception\OutOfBoundsException both extend their respective SPL exception classes. \OutOfBoundException extends \RuntimeException, so you if you try to catch \RuntimeException, you'll also catch \OutOfBoundsException. \Zend\Search\Lucene\Exception\OutOfBoundsException does not extends \Zend\Search\Lucene\Exception\RuntimeException, so you cannot catch \Zend\Search\Lucene\Exception\RuntimeException and also catch \Zend\Search\Lucene\Exception\OutOfBoundsException. try { throw new \OutOfBoundsException(); } catch (\RuntimeException $e) { die(ok); } die(not ok); try { throw new \Zend\Search\Lucene\Exception\OutOfBoundsException(); } catch (\Zend\Search\Lucene\Exception\RuntimeException $e) { die(ok); } die(not ok); So what exactly should be done here? It seems like there are two solutions; 1) it's not a valid use cases so ignore it; or 2) it is a valid use cases, so instead of creating concrete exceptions classes in components that extend SPL exceptions, marker interfaces have to be created for them and generic concrete classes be created (ie \Zend\Search\Lucene\Exception\RuntimeException becomes an interface and \Zend\Search\Lucene\Exception\GenericRuntimeException becomes a concrete class that implements the previous marker interface and extends \RuntimeException)?
Re: [fw-general] Problem with ZF2 exceptions and SPL exception inheritance
It's unfortunate that this scheme breaks down in this use case. The problem I see with the current approach is we're using SPL classnames but not maintaining their inheritance structures, resulting in some confusion. The proposal about exceptions in ZF2 should document this breakdown with something about component exceptions that extend SPL exceptions will not follow the same inheritance structure as the underlying SPL exception. Just to clarify one point. Alternately, we do as you suggest, and make low-level exceptions, such as RuntimeException, interfaces within the ZF hierarchy, allowing for a slightly richer experience. However, that means you cannot throw a concrete RuntimeException from that component. Trade-offs. It's still possible, just not very pretty. interface \Zend\Search\Lucene\Exception\RuntimeException extends \Zend\Search\Lucene\Exception {} interface \Zend\Search\Lucene\Exception\OutOfBoundsException extends \Zend\Search\Lucene\RuntimeException {} // mimics the SPL exception inheritance tree class \Zend\Search\Lucene\Exception\GenericRuntimeException extends \RuntimeException implements \Zend\Search\Lucene\Exception\RuntimeException {} class \Zend\Search\Lucene\Exception\GenericOutOfBoundException extends \GenericOutOfBoundException implements \Zend\Search\Lucene\Exception\OutOfBoundsException {} This addresses all the use cases, but now you've got parallel inheritance structures and well... just look at that mess... let me be the first to say, yuck.
[fw-general] New Proposal: Zend_Controller_Plugin_SessionExpire
Zend_Controller_Plugin_SessionExpire is a Zend_Controller plugin that provides userland control of session expiration by tracking a users last access time and redirecting to a custom module/controller/action if a timeout is exceeded. http://framework.zend.com/wiki/display/ZFPROP/Zend_Controller_Plugin_SessionExpire Any feedback would be appreciated.
Re: [fw-general] Zend_Service_Twitter not working
Here's my github repo for Zend_Service_Twitter_Oauth, based on 1.10.5: http://github.com/onyxraven/ZF-Zend_Service_Twitter_OAuth On Sun, Jun 27, 2010 at 10:26 PM, Justin Hart onyxra...@gmail.com wrote: This is correct. I personally had to delay upgrading the Twitter component on Twitgoo until later because I still have clients logging in with username/password credentials - so a oauth-only solution was not feasible. This will be forced to change in a few weeks (http://dev.twitter.com/pages/oauth_faq says Aug16). You can find my interim twitter oauth extension here http://bitbucket.org/onyxraven/zend-contrib/src/tip/zs-Twitter-Oauth/ - I'll be moving that to git this week with an updated version, and will link back there as well.. On Sun, Jun 27, 2010 at 8:26 PM, Shaun Farrell farrel...@gmail.comwrote: Zend_Service_Twitter as of 1.10.6 requires oauth for logging in. Shaun J. Farrell Washington, DC On Sun, Jun 27, 2010 at 10:10 PM, Jack Houghton j...@hicus.com wrote: Robert, Unfortunately, I may not be of that much help. I ran into the same issue and switched to using cURL for my twitter feed (without OAuth). I posted this to the list a month back and came away with the realization that Zend_Service_Twitter was simply broken and based on cURL working with the user/pass authorization I can confirm that OAuth is not yet required. Please let me know if you get anywhere with this. -Jack- -- *From:* robert mena [mailto:robert.m...@gmail.com] *Sent:* Sunday, June 27, 2010 7:32 PM *To:* Zend Framework *Subject:* [fw-general] Zend_Service_Twitter not working Hi, I am trying to use Zend_Service_Twitter (ZF10.6.5 / PHP 5.3.2) but it always complains about the credentials even tough I've tested the username/password. I found a post somewhere that Twitter will/was no longer accept this and I'll be 'forced' to use Oauth. Is this true? In that case does anybody have a quickstart? The manual of Zend_Service_Twitter does not cover that and I am unsure of how to add the capability for my app to post stuff automatically No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.830 / Virus Database: 271.1.1/2966 - Release Date: 06/27/10 14:35:00
Re: [fw-general] Zend_Service_Twitter not working
This is correct. I personally had to delay upgrading the Twitter component on Twitgoo until later because I still have clients logging in with username/password credentials - so a oauth-only solution was not feasible. This will be forced to change in a few weeks (http://dev.twitter.com/pages/oauth_faq says Aug16). You can find my interim twitter oauth extension here http://bitbucket.org/onyxraven/zend-contrib/src/tip/zs-Twitter-Oauth/ - I'll be moving that to git this week with an updated version, and will link back there as well.. On Sun, Jun 27, 2010 at 8:26 PM, Shaun Farrell farrel...@gmail.com wrote: Zend_Service_Twitter as of 1.10.6 requires oauth for logging in. Shaun J. Farrell Washington, DC On Sun, Jun 27, 2010 at 10:10 PM, Jack Houghton j...@hicus.com wrote: Robert, Unfortunately, I may not be of that much help. I ran into the same issue and switched to using cURL for my twitter feed (without OAuth). I posted this to the list a month back and came away with the realization that Zend_Service_Twitter was simply broken and based on cURL working with the user/pass authorization I can confirm that OAuth is not yet required. Please let me know if you get anywhere with this. -Jack- -- *From:* robert mena [mailto:robert.m...@gmail.com] *Sent:* Sunday, June 27, 2010 7:32 PM *To:* Zend Framework *Subject:* [fw-general] Zend_Service_Twitter not working Hi, I am trying to use Zend_Service_Twitter (ZF10.6.5 / PHP 5.3.2) but it always complains about the credentials even tough I've tested the username/password. I found a post somewhere that Twitter will/was no longer accept this and I'll be 'forced' to use Oauth. Is this true? In that case does anybody have a quickstart? The manual of Zend_Service_Twitter does not cover that and I am unsure of how to add the capability for my app to post stuff automatically No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.830 / Virus Database: 271.1.1/2966 - Release Date: 06/27/10 14:35:00
Re: [fw-general] Zend_Service_Twitter: Cannot update status using Zend_Oauth_Token_Access
if you print_r the whole twitter object, do you see your Oauth_Token_Access in the structure? On Thu, Jun 24, 2010 at 3:58 AM, Marcus Stöhr daf...@soundtrack-board.dewrote: Hi there. I'm using Zend_Oauth_Consumer to retrieve an access token from Twitter which is working fine. I instatiate Zend_Service_Twitter using the access token like this: $options = array( 'accessToken' = unserialize($userConnection-getAccessToken()), 'username'= $userConnection-getId() ); $twitter = new Zend_Service_Twitter($options); No exceptions are being thrown or such and when I try to update the status, I get the following response: object(Zend_Rest_Client_Result)[131 ] protected '_sxml' = object(SimpleXMLElement)[136 ] public 'request' = string '/1/statuses/update.xml' (length=22) public 'error' = string 'Incorrect signature' (length=19) protected '_errstr' = null The isAuthorised()-method gives me true, so I assume everything worked fine. Any suggestions were the problems lies? - Marcus
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 djvir...@gmail.com 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 onyxra...@gmail.com 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.
[fw-general] Zend_Application_Resource_Smtp is ready for review
Hello everyone, The Zend_Application_Resource_Smtp proposal is ready for review. It is a simple resource class for the Zend_Mail_Transport_Smtp class. Any feedback would be appreciated. The proposal can be found here: http://framework.zend.com/wiki/display/ZFPROP/Zend_Application_Resource_Smtp+-+Justin+Hendrickson
Re: [fw-general] Zend_Filter_Input and EscapeFilter
I think you mean the getUnescaped() method :-) Thomas Weidner wrote: Try getUnescapedValue() to get the unescaped value. Greetings Thomas Weidner, I18N Team Leader, Zend Framework http://www.thomasweidner.com - Original Message - From: Serkys sergeym...@gmail.com To: fw-general@lists.zend.com Sent: Friday, September 04, 2009 11:27 AM Subject: [fw-general] Zend_Filter_Input and EscapeFilter Hello. I use Zend_Filter_Input and don't want to use escapeFilter. But Zend_Filter_Input requires it. How can I make it optional? -- View this message in context: http://www.nabble.com/Zend_Filter_Input-and-EscapeFilter-tp25291137p25291137.html Sent from the Zend Framework mailing list archive at Nabble.com.
Re: [fw-general] Zend_Filter_Input and EscapeFilter
The default behavior of zend_input_filter is escaping the data, it's not possible to disable this behavior in a way of setEscape( false ) or something like that. As Thomas and I told you, the easiest way of getting unescaped data is to call the getUnescaped( $key ) method. There is an other way of 'disabling' the default escape behavior. You could create a custom class My_Filter_DoNothing, which implements the Zend_Filter_Interface and set that filter as the default escape filter (see the setDefaultEscapeFilter() method ). The filter( $value ) method of this class returns the $value directly, without modifications. The data will still be 'filtered' when you call $input-{key} or $input-getEscaped( $key ), but the used filter does nothing Justin Serkys wrote: It's not important for me, escaped or unescaped values I will use. I think I can don't use escaper, becouse it's not need for me. I wanna disable escaper.
Re: [fw-general] Bootstrapping modules
Hi Vadim, Not sure if this answers your question - but this is my solution to bootstrapping and encapsulating modules. I would be happy to hear others feedback. I'm using the following module bootstrap class to bootstrap my modules ... I have plans to extend the Module_Bootstrap class to do this automatically (similar to how is does autoloading), but in the mean time I have this. class Module1_Bootstrap extends Zend_Application_Module_Bootstrap { protected function _initModuleConfig() { $moduleConfig = new Zend_Config_Ini(APPLICATION_PATH . '/modules/' . $moduleName . '/configs/module.ini', APPLICATION_ENV); Zend_Registry::set($moduleName, $moduleConfig); } } This is the directory structure of my application. All module configs are placed in module/configs/module.ini and loaded via the module bootstrap. This allows me to black box my modules. I really wish the default module acted the same way so I could also encapsulate it's config. But since it doesn't all default configs end up in application.ini /application /configs /application.ini /modules /default /controllers /models /views /services /module1 /configs /module.ini /controllers /models /services /views /bootstrap.php /module2 /configs /module.ini /controllers /models /views /bootstrap.php A thanks to Keith Pope ... Your examplehttp://code.google.com/p/zendframeworkstorefront/source/browse/#svn/store front code got me moving in the right direction a few weeks back. On Thu, May 7, 2009 at 3:20 AM, Vadim Gabriel vadim...@gmail.com wrote: Hey, Thanks for that, It's a good start. The reason i want to separate the admin from the other modules is because i will have lots of controllers for each module, Each module will have several layouts, each one has to load different public resources from the public folder so it's important for me to make a complex modeler structure so switching layouts, views, resources, controllers separation and adding more modules at a later time will be easier. Since there are no resources about it, You need to dig trough the PHP files of the ZF to figure out how the ZF works with modules step-by-step that sometimes takes time (too much time). I am still looking to get this done the way i showed above, If your book will cover that area as well then you got yourself your first buyer and reader. Thanks. On Thu, May 7, 2009 at 11:00 AM, keith Pope mute.p...@googlemail.comwrote: 2009/5/7 Vadim Gabriel vadim...@gmail.com: OK i have added a bootsrap.php file for each module in the module root directory. For some reason it won't load that bootstrap file. For example my default module directory is as follows: -default --bootsrap.php --controllers --layouts --views my bootsrap.php file has the class Default_Bootstrap extends Zend_Application_Module_Bootstrap and it consists of an _initView method which never gets called. but it routes to the index controller of the default module. Meaning it works just with nothing set, not view, no layout no nothing. Currently the default module is skipped, look inside the modules resource to see. Therefore Zend_App assume that the main bootstrap file is your default bootstrap file. This will change at some point, I had a conversation with Matthew about it some time ago and there are various ideas about configuring individual modules. I have an example of bootstrapping with modules here: http://code.google.com/p/zendframeworkstorefront I should be updating it in the next few weeks to include multiple modules as currently it has only one. Also I use a route to create the admin section rather than a separate module, this way you can keep all your module code together in one place. Hope that makes sense :) Any idea why? Thanks. On Wed, May 6, 2009 at 6:24 PM, Vadim Gabriel vadim...@gmail.com wrote: P.S I do not use the Zend_Tool yet since it doesn't support modules...Yet (as far as i know) On Wed, May 6, 2009 at 6:23 PM, Vadim Gabriel vadim...@gmail.com wrote: Thanks everyone, I think since there are so many people wondering about it, A blog post/tutorial will be a good idea *hint Matthew hint* i will take a look at those once i am at the office tomorrow. Vince. On Wed, May 6, 2009 at 5:33 PM, Jurian Sluiman subscr...@juriansluiman.nl wrote: I think (but am not sure about it) you can add view helper paths in the module bootstrap. You need to specify them for each module, that's correct. But it's not much work to have an init method in each bootstrap class adding a path to the view (only some duplicated code...). -- Jurian
[fw-general] Zend_Application Bootstrapping
Hello All, I've begun playing with Zend_Application. I really like the Idea. However I am struggling with how to organize the bootstrap and associated files within my project. This is my current setup ... index.php ?php require_once '../application.php'; ? application.php ... ?php // Set the Include path .. // Set the Application configuration ... // Bootstrap require_once 'Zend/Application.php'; $application = new Zend_Application($configSection,$applicationConfig); $application-bootstrap(); $application-run(); ? boostrap.php ... class Bootstrap extends Zend_Application_Bootstrap_Base { // init functions dispatch } How are others handling this? Thanks
[fw-general] Zend_Form_Element_File and previewing
I'm trying to create a Zend_Form that contains a couple of Zend_Form_Element_File elements, amongst other things. I want to support previewing the content before submitting, but I'm not sure how to make the file elements stick from the preview to the submit. Has anyone found a good way of handling this?
Re: [fw-general] How can i pass a variable using zend_paginator
Hi Anees, I have created a custom class which extends the base class of Zend_Paginator to solve this problem. I then add a custom getter and setter to add additional view parameters to the new pagination object. Finally I changed the __toString() and render() functions to pass in the additional parameters to the rendering of the pagination control using the new getter. Not sure if this is a perfect solution but it worked for me. Maybe Zend_Paginator base class should included these additional getters and setters for passing additional information to the pagination control view rendering? Class Jnb_Paginator extends Zend_Paginator { protected $addtionalViewParams = null; public static function factory($data, $adapter = self::INTERNAL_ADAPTER, array $prefixPaths = null) { if ($adapter == self::INTERNAL_ADAPTER) { if (is_array($data)) { $adapter = 'Array'; } else if ($data instanceof Zend_Db_Table_Select) { $adapter = 'DbTableSelect'; } else if ($data instanceof Zend_Db_Select) { $adapter = 'DbSelect'; } else if ($data instanceof Iterator) { $adapter = 'Iterator'; } else if (is_integer($data)) { $adapter = 'Null'; } else { $type = (is_object($data)) ? get_class($data) : gettype($data); /** * @see Zend_Paginator_Exception */ require_once 'Zend/Paginator/Exception.php'; throw new Zend_Paginator_Exception('No adapter for type ' . $type); } } $pluginLoader = self::getAdapterLoader(); if (null !== $prefixPaths) { foreach ($prefixPaths as $prefix = $path) { $pluginLoader-addPrefixPath($prefix, $path); } } $adapterClassName = $pluginLoader-load($adapter); return new self(new $adapterClassName($data)); } public function setAddtionalViewParams($params) { $this-addtionalViewParams = $params; } public function getAddtionalViewParams() { return $this-addtionalViewParams; } public function __toString() { try { // This statement has added a call to get the addtional view params $return = $this-render(null,$this-getAddtionalViewParams()); return $return; } catch (Exception $e) { trigger_error($e-getMessage(), E_USER_WARNING); } return ''; } public function render(Zend_View_Interface $view = null, $paginationControlParams = null) { if (null !== $view) { $this-setView($view); } $view = $this-getView(); // this statement has been modified to inject the addtional params into the pagination control view return $view-paginationControl($this,null,null,$paginationControlParams); } } On Thu, Mar 26, 2009 at 2:21 AM, Anees anees_m...@yahoo.com wrote: Hi, I am using zend_paginator class to generate the Paging script And it is working well. But i need to pass a variable other than 'page' as GET how could i do this? My current script is $paginator = Zend_Paginator::factory($result); $paginator-setView($this-view); $paginator-setItemCountPerPage($site_rec_per_page); $paginator-setCurrentPageNumber($this-view-page); $this-view-paginator = $paginator; [here $result = recordset] at present when i click on page 2 it comes in URL as mysite.com/ads/page/2 but i want to pass a location id to the next page so the URL will be something like mysite.com/ads/page/2/location_id/345 Please Help Regards Anees -- View this message in context: http://www.nabble.com/How-can-i-pass-a-variable-using-zend_paginator-tp22716996p22716996.html Sent from the Zend Framework mailing list archive at Nabble.com.
[fw-general] Re: S3 and Queue
The main API should be close to frozen at this point and the Stream wrapper utilizes it. I have not had time to write any unit tests and documentation. The API could probably use a little more testing, specifically around how Amazon handles 100 Continue headers. I was trying to figure out a way to support that in the S3 class, but I think we'd need to add it to Zend_Http_Client somewhere (I submitted an issue on this). Range support on GET requests also seems a little off (the code works as intended, but Amazon wasn't returning just the specified ranges and would return everything, but I could have done something incorrectly). That's about it. I hope someone can finish it up. Thanks. -Justin Ralph Schindler wrote: So it looks like the API is looking pretty good at this point, and its somewhat different (in a better way) than the one laid out in the proposal. Is there any chance you can give us a state of the union on the component, and the directions you'd like it to go in? How much if any is done in the way of unit tests/docs. Etc. Just want to get a sense of what level of work is left. It appears a lot of people are interested in this! Thanks! Ralph On 1/27/09 11:46 AM, Justin Plock jpl...@gmail.com wrote: Correct. Thanks. -Justin On 1/27/09, Ralph Schindler ralph.schind...@zend.com wrote: Just to confirm, this is your code right: http://framework.zend.com/svn/framework/laboratory/library/Zend/Service/Amaz on/S3.php -ralph On 1/25/09 9:33 PM, Justin Plock jpl...@gmail.com wrote: Would anyone like to take over development of my two proposals: Zend_Service_Amazon_S3 and Zend_Queue? I don't have the bandwidth right now to complete these two projects and I hate to leave them sit in the laboratory and incubator. Thanks. -Justin -- Ralph Schindler Software Engineer | ralph.schind...@zend.com Zend Framework| http://framework.zend.com/
[fw-general] S3 and Queue
Would anyone like to take over development of my two proposals: Zend_Service_Amazon_S3 and Zend_Queue? I don't have the bandwidth right now to complete these two projects and I hate to leave them sit in the laboratory and incubator. Thanks. -Justin
[fw-general] pdo_pgsql connection info string error
Hello all, I'm using Zend_Db to connect to a postgresql database server, works fine until today when I added a new login role with a whitespace in it's rolename. When I try to connect to the database with that rolename, an exception tells me there is something wrong with the rolename. I tried to connect to the database with that rolename in PgAdmin III and that works fine, so postgresql accepts a rolename with a whitespace. Some code I used to test: // With my own rolename it works fine $aParams = array( 'host'= 'localhost', 'username'='justin', 'password'= '', 'dbname'= 'test' ); $oDb = Zend_Db::factory( 'pdo_pgsql', $aParams ); $oDb-prepare( 'SELECT 1' )-execute(); // But this fails $aParams = array( 'host'= 'localhost', 'username'='jan willem', 'password'= '', 'dbname'= 'test' ); $oDb = Zend_Db::factory( 'pdo_pgsql', $aParams ); $oDb-prepare( 'SELECT 1' )-execute(); *Fatal error*: Uncaught exception 'Zend_Db_Adapter_Exception' with message 'SQLSTATE[08006] [7] missing = after willem in connection info string' in /usr/local/ZendFramework/1.7.0/library/Zend/Db/Adapter/Pdo/Abstract.php:143 Stack trace: #0 /usr/local/ZendFramework/1.7.0/library/Zend/Db/Adapter/Pdo/Abstract.php(167): Zend_Db_Adapter_Pdo_Abstract-_connect() #1 /home/justin/domains/dev.intern.basisscholenonline.nl/public_html/postgres.php(19): Zend_Db_Adapter_Pdo_Abstract-prepare('SELECT 1') #2 {main} thrown in */usr/local/ZendFramework/1.7.0/library/Zend/Db/Adapter/Pdo/Abstract.php* on line *143* I figured out that escaping the whitespace fixes this problem, but shouldn't this been done by Zend_Db instead of myself? Thnx and greetings. Justin Verweel p.s. Used ZF version is 1.7.1
[fw-general] Re: pdo_pgsql connection info string error
Hi A.J. I escape the whitespace with a backslash $aParams = array( 'host'= 'localhost', 'username'='jan\ willem', 'password'= 'bsouser', 'dbname'= 'bso' ); $oDb = Zend_Db::factory( 'pdo_pgsql', $aParams ); $oDb-prepare( 'SELECT 1' )-execute(); Thanks for the zf-issue. I must have missed it, when I searched the issue list today. Justin a...@ajbrown.org wrote: Hi Justin, How did you escape the whitespace? did you use square brackets? - A.J. Brown
[fw-general] Re: S3 Service / CDN using ZF
robert mena wrote: Hi, I've searched the archives but could not find anything new about a Zend_S3 (for Amazon's S3 service). The idea was dropped? I'd like to use Amazon's S3 to store image files and direct the users to their servers when they are not local. I'd need to use some GeoIP or other method to define the URL to serve the users. Thanks Zend_Service_Amazon_S3 is in the incubator if you'd like to try it out. You register it as a PHP stream and then use it like you'd access normal files. -Justin
[fw-general] Re: Zend_Net Package?
A.J. Brown wrote: Hello all, I wrote a library for matching IP addresses, ranges, and networks against eachother with support for subnet masks, CIDR, and IPv6 a few months ago. It's useful for writing IP filters (firewall-esque) and such. It uses bitwise mathematical calculations to do the matching, so it's quick and solid. I'd like to adapt it into Zend Framework. What are your thoughts on creating a Zend_Net package? Here are some quick off-the-top classes I think would be useful: Zend_Net_Address (for example) * Class to represent and translate IP addresses (IPv4 - IPv6 for example) * Class to represent and translate network addresses * Class to represent other protocol addresses, such as MAC address * Class to handle matching an input IP or range against a pool of classes from the above examples quick ex: $oNetwork = new Zend_Net_Address_Network_IPv4( '192.168.0.0', '255.255.255.0' ); // give me an array of Zend_Net_Address_Host_IPv4 objects within this network $aAddressesIp4 = $oNetwork-getAddresses(); // tell me the class of some IPv4 address $oHost = new Zend_Net_Address_IPv4( $sUserInput ); echo $oHost-getNetworkClass(); // is the address a private address? echo $oHost-isPrivate() ? 'yes' : 'no'; What are your thoughts? I can think of a few use-cases where this would be useful for rapid development and easy cooperation with the rest of Zend Framework. -- A.J. Brown Zend Certfied PHP Engineer HOME: http://ajbrown.me BLOG: http://coding-adventures.blogspot.com Hi A.J., I'd be interested in this class. Have you submitted a CLA to Zend? If so, why don't you submit a proposal at http://framework.zend.com/wiki/display/ZFPROP/Home Thanks. -Justin
[fw-general] View Helper Repository?
Does anyone know if there is some sort of site which is collecting useful view helpers to use? Might be a good idea. In any case, here is a view helper I use to convert a UNIX timestamp stored as UTC to a user-defined timezone and locale: class My_View_Helper_FormatDate extends Zend_View_Helper_Abstract { /** * Format a timestamp in the user's locale and timezone * * @param integer $timestamp * @param string $format * @return string */ public function formatDate($timestamp, $format=Zend_Date::DATE_SHORT) { if (Zend_Registry::isRegistered('locale')) { // en_US $locale = Zend_Registry::get('locale'); } else { $locale = null; } $date = new Zend_Date($timestamp, Zend_Date::TIMESTAMP, $locale); if (Zend_Registry::isRegistered('timezome')) { // America/New_York $date-setTimezone(Zend_Registry::get('timezone')); } return $date-get($format, $locale); } } Then, as long as 'locale' and 'timezone' variables are set in Zend_Registry, in my view I can do: ?php echo $this-formatDate($timestamp); ? -Justin
Re: [fw-general] how to get format action name without Action suffix?
Though I too would like to see methods in the dispatcher that would return the inflected action/controller/module name without the prefix/suffix, it's pretty easy to get around: $formatted = $dispatcher-formatActionName($unformatted); echo preg_replace('/Action$/', $formatted); // option 1 echo substr($formatted, 0, -6); // option 2 On Wed, Jul 9, 2008 at 11:18 AM, Jacky Chen [EMAIL PROTECTED] wrote: Hi, I want to get the format action name,but there just a method in Zend_Controller_Dispatcher_Abstract::formatActionName($unformatted), but it return the action name with the Action suffix. because action name or controller name can be, get.data,or get-data, for example.If i call the method getActionName() with Request,it just return the unformatted action name,and i want to test that if there is a getData action. I think it is convenient if there have a method return the format module(or controller,or action)name. There have one,but is protected.
Re: [fw-general] Dojo view helper in incubator and ready for testing
I'm pretty sure the problem is that you're trying to use Zend_Form with the new Dojo view helpers. Zend_Form_Decorator_Form is expecting to call Zend_View_Helper_Form::form() and when you add the Dojo helpers in, Zend_Form_Decorator_Form calls Zend_Dojo_View_Helper_Form::form(), which has a different signature. If you want to use Zend_Form with the new Zend_Dojo stuff, you can delete Zend_Dojo_View_Helper_Form or wait until the form stuff has been addressed. On Tue, Jul 8, 2008 at 8:33 AM, Matthew Weier O'Phinney [EMAIL PROTECTED] wrote: -- philip142au [EMAIL PROTECTED] wrote (on Tuesday, 08 July 2008, 06:14 AM -0700): Or can you suggest a setup of what version of ZF and what version of incubator files works? Current incubator works, but until the code is pushed to standard/library, the API may be in flux. -- Matthew Weier O'Phinney Software Architect | [EMAIL PROTECTED] Zend Framework | http://framework.zend.com/
Re: [fw-general] Dojo view helper in incubator and ready for testing
On a separate note, are their plans for a view helper for the Dijit.Editor widget? I was playing around with it last week and noticed a problem with submitting data from a Dijit.Editor (it appears to remove the textarea from the form) and I was wondering if/how you were going to handle that. On Tue, Jul 8, 2008 at 10:19 AM, Matthew Weier O'Phinney [EMAIL PROTECTED] wrote: -- Justin Hendrickson [EMAIL PROTECTED] wrote (on Tuesday, 08 July 2008, 10:12 AM -0500): I'm pretty sure the problem is that you're trying to use Zend_Form with the new Dojo view helpers. Zend_Form_Decorator_Form is expecting to call Zend_View_Helper_Form::form() and when you add the Dojo helpers in, Zend_Form_Decorator_Form calls Zend_Dojo_View_Helper_Form::form(), which has a different signature. If you want to use Zend_Form with the new Zend_Dojo stuff, you can delete Zend_Dojo_View_Helper_Form or wait until the form stuff has been addressed. Correct -- the dojo elements and decorators are incomplete at this time. I should have them working later today. (I was under the impression he was using just view helpers, and hence my original answer.) On Tue, Jul 8, 2008 at 8:33 AM, Matthew Weier O'Phinney [EMAIL PROTECTED] wrote: -- philip142au [EMAIL PROTECTED] wrote (on Tuesday, 08 July 2008, 06:14 AM -0700): Or can you suggest a setup of what version of ZF and what version of incubator files works? Current incubator works, but until the code is pushed to standard/library, the API may be in flux. -- Matthew Weier O'Phinney Software Architect | [EMAIL PROTECTED] Zend Framework | http://framework.zend.com/
[fw-general] Zend_Service_Amazon_S3 in laboratory
Hi Everyone, I recently committed Zend_Service_Amazon_S3 to the laboratory and am interested in any feedback anyone might be able to provide. This class is meant to be used as a PHP stream wrapper (stream_wrapper_register()) and that's primarily how my unit tests interface with the class as well. Since that is the way the class was intended to be used, should I try to test the class outside of the stream wrapper or leave the tests as-is? The tests do completely successfully when used with a valid AWS access key and secret key. Since each test case needs to have a valid bucket to test again, and I'm build and tearing down the bucket on each test, should I move that into the setUp() method instead? I haven't really written PHPUnit tests before so I'm looking for suggestions. Thanks. -Justin
Re: [fw-general] PHP 5.2.6 and Zend_Translate
I've just run into the same problem. Windows XP, PHP 5.2.6. I've isolated the problem to line 140: (Zend_Locale::isLocale((string) $info) On 5.2.6, (string) $info returns the complete relative pathname (../languages/en, ../languages/es). On Ubuntu 7.10 w/PHP 5.2.3 and Windows XP w/PHP 5.2.5 it returns simply the directory name. On Tue, May 6, 2008 at 3:08 PM, Robert Castley [EMAIL PROTECTED] wrote: WHOOPS! Spoke too soon, forgot to delete my cache. Still the same issue, I downloaded with Windows .zip of 5.2.6. Php.ini files are the same. Maybe there is an issue with the SPL in 5.2.6? Cheers, - Robert -Original Message- From: Robert Castley Sent: 06 May 2008 20:42 To: fw-general@lists.zend.com Subject: RE: [fw-general] PHP 5.2.6 and Zend_Translate WOW! You are good! Learnt another thing about PHP5. Sorry to trouble you (again!) Cheers, - Robert -Original Message- From: Thomas Weidner [mailto:[EMAIL PROTECTED] [EMAIL PROTECTED] ] Sent: 06 May 2008 20:26 To: Robert Castley; fw-general@lists.zend.com Subject: Re: [fw-general] PHP 5.2.6 and Zend_Translate Looks like you have not installed SPL. Directory scanning works with RecursiveDirectoryIterator and RecursiveIteratorIterator. When eigther of these two is not available the result would be like described from you. Greetings Thomas Weidner, I18N Team Leader, Zend Framework http://www.thomasweidner.com - Original Message - From: Robert Castley [EMAIL PROTECTED] To: fw-general@lists.zend.com Sent: Tuesday, May 06, 2008 9:13 PM Subject: RE: [fw-general] PHP 5.2.6 and Zend_Translate Hi, In my custom plugin ( http://framework.zend.com/wiki/x/p6o ) I do check for the language snippet if (!$translate-isAvailable($locale-getLanguage())) { $locale-setLocale('en'); } /snippet This works fine under PHP 5.2.5. By adding some trace I see the following: print_r(List languages (getList) : ); print_r($translate-getList()); HTTP_ACCEPT_LANGUAGE: en-gb List languages (getList) : Array ( [de] = de [en] = en [es] = es [fr] = fr [it] = it ) If I switch to PHP 5.2.6 (and nothing else changes) I get: print_r(List languages (getList) : ); print_r($translate-getList()); HTTP_ACCEPT_LANGUAGE: en-gb List languages (getList) : Array ( [en_GB] = en_GB ) Really strange ... It seems as though with PHP 5.2.6 it won't scan and pick up the other languages in the languages directory. - Robert -Original Message- From: Thomas Weidner [mailto:[EMAIL PROTECTED][EMAIL PROTECTED] ] Sent: 06 May 2008 19:39 To: Robert Castley; fw-general@lists.zend.com Subject: Re: [fw-general] PHP 5.2.6 and Zend_Translate This error is thrown by Zend_Translate when you try to translate a language which does not exist. I got no problem with 5.2.6, and you are free to add a issue. But you could help yourself and look which language exists before throwing in a new issue. Greetings Thomas Weidner, I18N Team Leader, Zend Framework http://www.thomasweidner.com - Original Message - From: Robert Castley [EMAIL PROTECTED] To: fw-general@lists.zend.com Sent: Tuesday, May 06, 2008 8:31 PM Subject: [fw-general] PHP 5.2.6 and Zend_Translate Scanning for language files with Zend_Translate was working beautifully with PHP 5.2.5. Trying out PHP 5.2.6 and this no longer works. Anyone else found the same? I get the error: Fatal error: Uncaught exception 'Zend_Translate_Exception' with message 'Language (en) has to be added before it can be used.' I am using my custom Plugin: http://framework.zend.com/wiki/x/p6o http://framework.zend.com/wiki/x/p6o Shall I log an issue? Or is this an issue with PHP itself? Robert W. Castley Macro 4 _ ___ This email has been scanned for all known viruses by the MessageLabs Email Security Service and the Macro 4 plc internal virus protection system. _ ___ __ __ This email has been scanned for all known viruses by the MessageLabs Email Security Service and the Macro 4 plc internal virus protection system. __ __ __ __ This email has been scanned for all known viruses by the MessageLabs Email Security Service and the Macro 4 plc internal virus protection system. __ __ This email has been scanned for all known viruses by the MessageLabs Email Security Service and the Macro 4 plc
Re: [fw-general] PHP 5.2.6 and Zend_Translate
Quick follow-up: Looks like it's a PHP 5.2.6 bug in Windows. I'm able to reproduce the behavior with: ?php $iterator = new RecursiveDirectoryIterator('/etc', RecursiveDirectoryIterator::KEY_AS_PATHNAME); foreach($iterator as $item) { echo (string) $item . \n; } KEY_AS_PATHNAME is the source of the problem. On 5.2.5 it returns just the filename and on 5.2.6 it returns the path information with the filename. On Wed, May 28, 2008 at 11:30 AM, Justin Hendrickson [EMAIL PROTECTED] wrote: I've just run into the same problem. Windows XP, PHP 5.2.6. I've isolated the problem to line 140: (Zend_Locale::isLocale((string) $info) On 5.2.6, (string) $info returns the complete relative pathname (../languages/en, ../languages/es). On Ubuntu 7.10 w/PHP 5.2.3 and Windows XP w/PHP 5.2.5 it returns simply the directory name. On Tue, May 6, 2008 at 3:08 PM, Robert Castley [EMAIL PROTECTED] wrote: WHOOPS! Spoke too soon, forgot to delete my cache. Still the same issue, I downloaded with Windows .zip of 5.2.6. Php.ini files are the same. Maybe there is an issue with the SPL in 5.2.6? Cheers, - Robert -Original Message- From: Robert Castley Sent: 06 May 2008 20:42 To: fw-general@lists.zend.com Subject: RE: [fw-general] PHP 5.2.6 and Zend_Translate WOW! You are good! Learnt another thing about PHP5. Sorry to trouble you (again!) Cheers, - Robert -Original Message- From: Thomas Weidner [mailto:[EMAIL PROTECTED][EMAIL PROTECTED] ] Sent: 06 May 2008 20:26 To: Robert Castley; fw-general@lists.zend.com Subject: Re: [fw-general] PHP 5.2.6 and Zend_Translate Looks like you have not installed SPL. Directory scanning works with RecursiveDirectoryIterator and RecursiveIteratorIterator. When eigther of these two is not available the result would be like described from you. Greetings Thomas Weidner, I18N Team Leader, Zend Framework http://www.thomasweidner.com - Original Message - From: Robert Castley [EMAIL PROTECTED] To: fw-general@lists.zend.com Sent: Tuesday, May 06, 2008 9:13 PM Subject: RE: [fw-general] PHP 5.2.6 and Zend_Translate Hi, In my custom plugin ( http://framework.zend.com/wiki/x/p6o ) I do check for the language snippet if (!$translate-isAvailable($locale-getLanguage())) { $locale-setLocale('en'); } /snippet This works fine under PHP 5.2.5. By adding some trace I see the following: print_r(List languages (getList) : ); print_r($translate-getList()); HTTP_ACCEPT_LANGUAGE: en-gb List languages (getList) : Array ( [de] = de [en] = en [es] = es [fr] = fr [it] = it ) If I switch to PHP 5.2.6 (and nothing else changes) I get: print_r(List languages (getList) : ); print_r($translate-getList()); HTTP_ACCEPT_LANGUAGE: en-gb List languages (getList) : Array ( [en_GB] = en_GB ) Really strange ... It seems as though with PHP 5.2.6 it won't scan and pick up the other languages in the languages directory. - Robert -Original Message- From: Thomas Weidner [mailto:[EMAIL PROTECTED][EMAIL PROTECTED] ] Sent: 06 May 2008 19:39 To: Robert Castley; fw-general@lists.zend.com Subject: Re: [fw-general] PHP 5.2.6 and Zend_Translate This error is thrown by Zend_Translate when you try to translate a language which does not exist. I got no problem with 5.2.6, and you are free to add a issue. But you could help yourself and look which language exists before throwing in a new issue. Greetings Thomas Weidner, I18N Team Leader, Zend Framework http://www.thomasweidner.com - Original Message - From: Robert Castley [EMAIL PROTECTED] To: fw-general@lists.zend.com Sent: Tuesday, May 06, 2008 8:31 PM Subject: [fw-general] PHP 5.2.6 and Zend_Translate Scanning for language files with Zend_Translate was working beautifully with PHP 5.2.5. Trying out PHP 5.2.6 and this no longer works. Anyone else found the same? I get the error: Fatal error: Uncaught exception 'Zend_Translate_Exception' with message 'Language (en) has to be added before it can be used.' I am using my custom Plugin: http://framework.zend.com/wiki/x/p6o http://framework.zend.com/wiki/x/p6o Shall I log an issue? Or is this an issue with PHP itself? Robert W. Castley Macro 4 _ ___ This email has been scanned for all known viruses by the MessageLabs Email Security Service and the Macro 4 plc internal virus protection system. _ ___ __ __ This email has been scanned for all known viruses by the MessageLabs Email Security Service and the Macro 4 plc internal virus protection system
[fw-general] Timezone recommendations?
I'm trying to create a list of translated timezones, but I'm finding the variety of options pretty overwhelming. I wanted to avoid having to store GMT offsets and DST flags, and instead store PHP area/location values (http://us.php.net/manual/en/timezones.php) which I could fetch via timezone_identifiers_list() ( http://us.php.net/manual/en/function.timezone-identifiers-list.php), but it seems to be pretty impractical to display that entire list to end users. There's a lot of ambiguity in list as well. For example, US/Arizona and America/Phoenix; America/Havana and Cuba; UTC and UCT. Additionally, PHP doesn't offer any translations so there was no way I was going to do that myself. I thought I'd have a little more luck using Zend_Locale getting translations, so I looked at the CityToTimezone list. For some reason, Zend_Locale_Data::getList('en', 'CityToTimezone') only returns three results. Other locales returned various different counts (es: 83, el: 293), so I'm a bit confused how to use it. I also tried the WindowsToTimezone list which seems promising as a compromise of completeness vs usability, but there were ambiguous entries (US Mountain and Mountain) in the list and none of the results were coming back translated. I tried search Google for a bit, but I wasn't able to find any recommendations or guidelines for timezone selection, so I'm at a dead end. Any suggestions?
[fw-general] [#ZF-2324] Attachment corruption with MS Exchange
Could [#ZF-2324] get some attention? It's been out there for 3.5 months and still isn't working. It'd be a very simple fix to make the LINELENGTH configurable. Alternatively, I have access to an MS Exchange server at work, so I can run tests if needed.
Re: [fw-general] Zend_Mail SMTP Threading?
Steven Brown wrote: It appears as though the local server waits for the SMTP commands to finish before it returns a result to CURL, whereas directly accessing my bootstrap allows the SMTP commands to run in the background almost as a separate thread. i doubt there are any separate threads here. the basic issue is that smtp commands finishing != message delivered to intended recipients mailbox. usually, smtp commands finishing in php code just means the mail server has accepted the message into its queue. so: time a: smtp commands finish in php code time a + n: pop commands run time a + N: message gets to user mailbox if n is greater than N, then your tests will run ok. if not, then they wont. N is not dependent on your scripts or tests, but on an external process - the mail server. so, the simplest thing to do is to make n larger by putting a sleep call in before you run the pop checks. another less simple approach is to use mock objects to represents the mail process. make sense? Cheers, Steven cheers justin
[fw-general] ZF-compatible S3 class
Hi Everyone, I just wanted to let everyone know that I created a ZF-compatible Amazon S3 PHP user-stream wrapper available on Google Code. http://code.google.com/p/php-s3/ I'd be interested in feedback for this class. Thanks. -Justin
[fw-general] Re: Amazon SQS Class
Justin Plock wrote: Hi Everyone, Besides my S3 class, I also wrote a queuing class which interfaces with Amazon SQS. I was thinking of submitting a proposal for a Zend_Queue which had various backend adapters (SQS, Database, Files, Zend_Cache). Would anyone have a use for this? Thanks. -Justin Ok, I've started the proposal at http://framework.zend.com/wiki/display/ZFPROP/Zend_Queue+-+Justin+Plock I'll submit it for review after I finish it up. Thanks. -Justin
[fw-general] Amazon SQS Class
Hi Everyone, Besides my S3 class, I also wrote a queuing class which interfaces with Amazon SQS. I was thinking of submitting a proposal for a Zend_Queue which had various backend adapters (SQS, Database, Files, Zend_Cache). Would anyone have a use for this? Thanks. -Justin
[fw-general] Zend_Form multipage examples?
I'm trying to put together a simple Zend_Form setup for a multipaged form, but the documentation on implementing the multipage part is a bit sparse. Once the form object is setup with the subforms, what's the right way to render and validate the subforms and process the results? This is what I have right now: ?php require_once 'ApplicationController.php'; require_once 'Zend/Form.php'; class IndexController extends ApplicationController { public function siteInformationAction() { $subform = $this-_getForm()-getSubForm('site_information'); if ($this-getRequest()-isPost() $subform-isValid($this-getRequest()-getPost())) { return $this-getHelper('redirector')-gotoRoute( array( 'action' = 'personalInformation' ) ); } $this-view-form = $subform; $this-render('form'); } public function personalInformationAction() { $subform = $this-_getForm()-getSubForm('personal_information'); if ($this-getRequest()-isPost() $subform-isValid($this-getRequest()-getPost())) { var_dump($this-_getForm()-getValues()); exit; } $this-view-form = $subform; $this-render('form'); } private function _getForm() { return new Zend_Form(array( 'method' = 'POST', 'subforms' = array( 'site_information' = new Zend_Form(array( 'elements' = array( 'username' = array( 'text', array( 'label' = 'Username', 'required' = true, 'validators' = array( 'NotEmpty' ) ) ), 'password' = array( 'password', array( 'label' = 'Password', 'required' = true, 'validators' = array( 'NotEmpty' ) ) ), 'submit_site_information' = array( 'submit', array( 'value' = 'Next Page' ) ) ) )), 'personal_information' = new Zend_Form(array( 'elements' = array( 'name' = array( 'text', array( 'label' = 'Name', 'required' = true, 'validators' = array( 'NotEmpty' ) ) ), 'street' = array( 'text', array( 'label' = 'Street', ) ), 'city' = array( 'text', array( 'label' = 'City' ) ), 'state' = array( 'text', array( 'label' = 'State' ) ), 'zip' = array( 'text', array( 'label' = 'Zip' ) ), 'submit_personal_information' = array( 'submit', array( 'value' = 'Submit' ) ) ) )) ) )); } } Unfortunately, I'm obviously missing something because var_dump($this-_getForm()-getValues()); is giving me array() . Is my approach completely off? Also, how do you go about preventing someone from manually going to the personalInformationAction()?
Re: [fw-general] Dispatcher/Bootstrap ZF 1.5 PR
thanks for the help everyone! On Feb 5, 2008, at 11:04 PM, Zarrar Shehzad wrote: Hi There is also an example project that you can download which has a default setup for zend framework to get you started: http://andries.systray.be/blog/2007/06/18/zend-framework-just-get-me-started-okay/ Zarrar On Feb 5, 2008 8:23 PM, Garri Santos [EMAIL PROTECTED] wrote: Hi! TIMTOWTDI you can take a look at the sample provided at: http://www.zend.com/en/resources/webinars/framework Zend Framework and Access Control Webinar cheers, Garri On Feb 6, 2008 6:15 AM, jmazzi [EMAIL PROTECTED] wrote: Hi, Could someone post an example of the correct way to create a dispatcher/bootstrap for MVC? Is there even a preferred method? -- View this message in context: http://www.nabble.com/Dispatcher-Bootstrap-ZF-1.5-PR-tp15299930s16154p15299930.html Sent from the Zend Framework mailing list archive at Nabble.com.
[fw-general] Re: PHP bug when calling save() on a newly created Zend_Db_Table_Row
I'm still looking for some help with this problem. I've experience the problem with both 1.0.0 and 1.0.1. If it is indeed a bug within PHP, does anyone have any resources on how I to do internal stack trace dumps for submitting the bug? On 8/1/07, Justin Hendrickson [EMAIL PROTECTED] wrote: I'm trying to create a row and save it, but I keep getting this error message: 'Cannot refresh row as parent is missing' I tracked the problem down to Zend_Db_Table_Row_Abstract, line 371: $primaryKey = $this-_getTable()-insert($this-_data); var_dump($primaryKey) shows it's null. Backtracking to insert() in Zend_Db_Table_Abstract, line 788: return $this-_db-lastInsertId(); I changed this to: $id = $this-_db-lastInsertId(); var_dump($id); return $id; This displayed '273', the next auto increment value for the database. For some reason, the value is correctly coming back from the Zend_Db_Adapter, but something is breaking the return value from Zend_Db_Table_Abstract::insert() to Zend_Db_Table_Row_Abstract::_doInsert(). I tested with PHP 5.2.1/Ubuntu 7.04 and PHP 5.2.3/Windows Server 2003 SP2. Has anyone else encountered this problem? Can anyone share any insight?
[fw-general] PHP bug when calling save() on a newly created Zend_Db_Table_Row
I'm trying to create a row and save it, but I keep getting this error message: 'Cannot refresh row as parent is missing' I tracked the problem down to Zend_Db_Table_Row_Abstract, line 371: $primaryKey = $this-_getTable()-insert($this-_data); var_dump($primaryKey) shows it's null. Backtracking to insert() in Zend_Db_Table_Abstract, line 788: return $this-_db-lastInsertId(); I changed this to: $id = $this-_db-lastInsertId(); var_dump($id); return $id; This displayed '273', the next auto increment value for the database. For some reason, the value is correctly coming back from the Zend_Db_Adapter, but something is breaking the return value from Zend_Db_Table_Abstract::insert() to Zend_Db_Table_Row_Abstract::_doInsert(). I tested with PHP 5.2.1/Ubuntu 7.04 and PHP 5.2.3/Windows Server 2003 SP2. Has anyone else encountered this problem? Can anyone share any insight?
Re: [fw-general] Re: a couple of suggestions on viewRenderer
Hi Matt, Are there any plans for you to provide what *you* do as a sample MVC application so some of us have some examples to go by? Digging through the documentation is rather time consuming and I end up having to look into the source code to figure it out anyway. (Yes, I have RT*M) Thanks. -Justin On 6/1/07, Matthew Weier O'Phinney [EMAIL PROTECTED] wrote: -- pat [EMAIL PROTECTED] wrote (on Friday, 01 June 2007, 12:07 PM -0500): I see, you have a view directory in each module, where as I have only one view directroy above the modules.. modules/ default/ blog/ news/ views/site-wide templates are here views/ commonly used view functions, wrappers, etc Where would you put your site-wide templates? More importantly, with so many different views you open the door to TEOM. The Evils Of Multiplicity. If something changes in these views you have to go into all those dirs and search all the views and make the changes. I *always* have a sitelevel view directory I use. I do it like this in my bootstrap: // after I've already instantiated the front controller object... $view = new Zend_View(array('basePath' = '/path/to/common/views')); $viewRenderer = Zend_Controller_Action_HelperBroker::getHelper('viewRenderer'); $viewRenderer-setView($view); The ViewRenderer *adds* view paths to the view object, instead of removing them. This allows me to do the above, and thus later inject rendered content into the sitewide template (as well as set additional variables to inject). It also allows me to define common templates used and included elsewhere. However, typically, the views for a given module are self-contained and do not need access to the sitelevel view scripts; only the sitewide template itself would. Thus, changes are kept to a minimum. So, to the contrary, no EOM. On a different subject. This bit bothers me. It seems like double-speak. It won't assemble it willy-nilly. That's the point of named segments -- they also allow you to order the output -- or later pull out the content piece by piece to manually assemble the final output. If it has already been rendered, where is the need to: pull out the content piece by piece If you are still mucking about with the view, it hasn't been fully rendered. I don't think of 'view' in the singular. I have many views, and a final response made up of a composite of those views. Please read up on the Two Step View pattern: http://www.martinfowler.com/eaaCatalog/twoStepView.html It's a common practice to render portions of the view and inject them into a final composite view. Lastly, on the subject of adding renderToString('form'); I agree, it should be trivial to add this to the viewRender, so why don't you? Post-1.0 at the earliest. If you want this as a feature, please add it to the tracker, and we'll see if the idea gets traction. I think most people are fine rendering to the response object. p.s. Allowing us to change where the viewRenderer automatically looks for the action script, should also be trivial. This can already be done. Please read the ViewRenderer documentation. -- Matthew Weier O'Phinney PHP Developer| [EMAIL PROTECTED] Zend - The PHP Company | http://www.zend.com/
Re: [fw-general] ViewRenderer Problems
I agree with Kevin. I prefer to keep all of my HTML open and close tags in one file and include self-contained sub-sections as necessary. I've begun using most of the other Zend-classes but this piece of MVC is a major stumbling block for me on adoption. Thanks. -Justin On 5/30/07, Kevin McArthur [EMAIL PROTECTED] wrote: List debate time =P The issue with this approach is that it becomes very difficult to visualize the end product -- and then, from the end product, to determine where a particular piece of HTML came from. Consider how difficult it can be to find a particular nested tag when traversing the DOM, for instance -- a container view is much more difficult to visualize for most people I'd think it'd be harder to figgure out the end product if its all in different templates and is being included from views controllers, plugins and helpers. The container approach is the same as OOP really, offering encapsulation. It also follows HTML, which is in-itself a container based appraoch (ie DOM). Consider the following templates layout.php --- html head ?= $scripts ? ?= $styles ? /head body ?= $body ? /body /html This is really easy to find a mismatched tag, and chase down unclosed elements. Sub elements can be sub-templates and so on... its all very separated. Thinking of this process linearly, is imho a lot more complicated as you have to match up a number of files that are not hierarchically distributed. I'm not sure why, in such a highly oop framework, the inclination would be to go to procedural style views? I try to limit exactly what templates a non-developer can work with, and in most cases, they should not have to do any logic; they simply indicate whether or not it should be included in the page, and what content should be passed into it. I also segregate templates into application templates (i.e., the general container for the application content), item templates (what individual items can be included into the application template), and finally the actual page-level template (which includes the header, footer, and sitewide navigation elements). Typically, any given content editor will only need to deal with the *content* for the application level, which might include choosing which items to utilize. It's a container approach, but differs from the one you propose as most of the actual work is done at the view level instead of within the controller. Templates should be easy to change and skin without bugging technical staff. This is a pretty common workflow. It's mostly for that workflow reason that I favor dumb templates with controllers doing all the work, especially when touching the model which might affect database state etc and make debugging a real super pain. Why would you want to have to trace templates (which were presumably coded by someone else) in order to follow the applications logic instead of simply tracing the controler/action chain. It's a question of centralized, clearly defined, demarcation of responsibility. However, I'm not going to try and convert you -- if the container paradigm works for you, then that's good, too. The question is how to make both paradigms easy to use for maximum adoption. I think for the bulk of those using ZF, however, the methods outlined for using the ViewRenderer and Two-Step View are going to work well, and something will be built on top of these for layout support. For those like yourself and Kevin, there will be alternate systems developed, but as to whether or not they will be included directly in ZF is another question. Two-Step view is too complicated right now. It requires understanding the dispatch process intimately, and authoring plugins (something i'd consider advanced, un-everyday use) This approach needs to be simplified with some sort of addMasterTemplate() + useMasterTemplate() or similar calls being added to the viewrenderer. Standardization on this is critical for easy adoption. I'm working on a solution, when I come up with something elegant, I'll share. Kevin On May 30, 2007, at 3:20 PM, Matthew Weier O'Phinney wrote: -- Kevin McArthur [EMAIL PROTECTED] wrote (on Wednesday, 30 May 2007, 12:59 PM -0600): Seems like a % of developers think about templates as a series of concatenated strings (header.tpl, content.tpl, footer.tpl) and others (like you+me) think about them as a series of containers. The viewrenderer somewhat presumes the former, but with a plugin can do the latter. I think of them as containers as well, but I also have each controller action doing a very discrete task, which means that any individual action is only rendering one chunk of the page. I then assemble my final view in a dispatchLoopShutdown() plugin. The main purpose of the named segment support in the response object was to facilitate exactly this sort of idea -- aggregate all your various content pieces, and then assemble them later in a larger container
Re: [fw-general] Really complications Zend_Controller is purpose ZF?
I'd love to see a tutorial, using ZF 1.0RC1 (or later) using Smarty. I myself have been trying to figure out how to migrate an existing code base where we used Smarty exclusively, over to the ZF MVC pattern. I've ended up having to disable both the ViewRenderer and the ErrorHandler plugin to start sifting through where to do the migration. Personally, I think the ZF MVC code should be a best practices of sort. ViewRenderer seems very much like an after-thought to me instead of integrating the View functionality into the Controller directly. I realize the time and effort people have put into all of this code, but at some point, I think we need to step back and K.I.S. That's my 2 cents. Thanks. -Justin On 5/29/07, Gunter Sammet [EMAIL PROTECTED] wrote: Matthew, thank you for your hard work and prompt responses. Here a few lines on my experience so far: I am pretty new to ZF and MVC. On top of that I want to implement Smarty as the template engine. Been spending a few days on reading the documentation, what I could find on the Internet and playing around with the zfdemo code. Still don't get the whole picture but it makes more and more sense. Figure it will take me another few days of playing around to understand it a bit more. Managed to get some views working through piecing together code pieces from several tutorials and the zfdemo app. I followed the emails in the last few weeks, so I knew that there were some changes that are not compatible. That's why I upgraded today to 1.0. This broke my setup with the Smarty view, injecting templates out of a template directory. Since I am still not very proficient in debugging the ZF and I had $frontController-throwExceptions(true) set, I didn't get the error message that it didn't find 'index/index.phtml'. It took me a few hours to figure it out and I am thinking about my potential new structure. Besides the above, I had to change my smarty view to use extends Zend_View_Abstract instead of implements Zend_View_Interface which required me to declare the _run method. For now till I have my new template structure, I managed to bypass the auto view settings by using the following lines of code; $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view); $viewRenderer-setViewBasePathSpec($tmplPath) -setViewScriptPathSpec('landing.tpl') -setViewScriptPathNoControllerSpec(' landing.tpl') -setViewSuffix('tpl'); Zend_Controller_Action_HelperBroker::addHelper($viewRenderer); //Zend_View_Controller_HelperBroker::addHelper($viewRenderer); NOTE: = --The sample code at http://framework.zend.com/manual/en/zend.controller.actionhelpers.html#zend.controller.actionhelpers.viewrenderer (paragraph 7.9) wants you to implement Zend_View_Controller_HelperBroker::addHelper($viewRenderer);. However, I didn't find a HelperBroker there. Seems to be the Zend_Controller_Action_HelperBroker that is meant there. Your changes make sense and should make the default setup easier. I will try to implement it as close as possible to be open for future refactoring. That's why I didn't use the $front-setParam ('noErrorHandler', true); If I understand it correctly, that should have solved my problem without changes. A good read for it is the migration page ( http://framework.zend.com/manual/en/zend.controller.migration.html#zend.controller.migration.fromzeroninethree) Hope these lines help some other users to figure it out a bit earlier and for you to understand the issues ZF newbies may face. Gunter
[fw-general] Where should error checking occur?
I'm trying to convert over an existing site over to using Zend_Db and Zend_Controller. I've got some error checking code in my Zend_Db_Table classes to make sure all of my required values are populated. I'm just asking in terms of a best practice, should this sort of error checking be moved up to the Controller so it is easier to communicate the error messages back to the user or do you think it should be tied to the Zend_Db_Table? Just looking for suggestions. Thanks. -Justin
Re: [fw-general] Where should error checking occur?
Thanks for the comments. So if my model was going to throw an error about a duplicate row, for example, you'd throw that as an exception then let the controller deal with that (i.e. format a nice error message for the user, or something)? Thanks. -Justin On 5/16/07, Ralph Schindler [EMAIL PROTECTED] wrote: Think of the controller/action the place to take user input, filter it, and pass it to the model. Generally speaking, the controller should be completely aware of what inputs your view is sending back (via the form naturally). If the controller is not getting the values (from $_POST or wherever), its the controllers job to pass some information to the view to alert the user. I like to think of models in such a way that they can operate in a platform independent manner, or in other words.. I can drop the same models I use in a web app, into a commandline version of the same app, and the models should not have to be altered in any way. If for some reason, you have not satisfied a requirement for a model, I generally allow it to throw an exception (as Zend_Db_Table_* does) and handle it gracefully in the controller. Those are just some ideas to start kicking around. -ralph Justin Plock wrote: I'm trying to convert over an existing site over to using Zend_Db and Zend_Controller. I've got some error checking code in my Zend_Db_Table classes to make sure all of my required values are populated. I'm just asking in terms of a best practice, should this sort of error checking be moved up to the Controller so it is easier to communicate the error messages back to the user or do you think it should be tied to the Zend_Db_Table? Just looking for suggestions. Thanks. -Justin
Re: [fw-general] Where should error checking occur?
How would I do something like this: 1.) present a form to the user 2.) user submits it and an error is generated 3.) either the controller or the model throws an exception 4.) the user will be presented with the same form they filed out, with all of their values still populated, but an error message would be displayed. How would I do something like that using the ErrorHandler plugin? I somehow need to get back into the controller action which generated the form, but also interject an error message into my view. Would I use the ErrorHandler plugin to set the error message in the view, then forward back to the previous controller/action, pre-populate all of the form fields, then display the form to the user with the error message? Are there any tutorials or best practices on this stuff yet? :) Thanks. -Justin On 5/16/07, Matthew Weier O'Phinney [EMAIL PROTECTED] wrote: -- Justin Plock [EMAIL PROTECTED] wrote (on Wednesday, 16 May 2007, 04:11 PM -0400): Thanks for the comments. So if my model was going to throw an error about a duplicate row, for example, you'd throw that as an exception then let the controller deal with that (i.e. format a nice error message for the user, or something)? Yep. Or you could ignore it in your controller, and use the new ErrorHandler plugin (enabled by default) to display an error message via your ErrorController. (I just moved the ErrorHandler controller plugin to core this afternoon.) On 5/16/07, Ralph Schindler [EMAIL PROTECTED] wrote: Think of the controller/action the place to take user input, filter it, and pass it to the model. Generally speaking, the controller should be completely aware of what inputs your view is sending back (via the form naturally). If the controller is not getting the values (from $_POST or wherever), its the controllers job to pass some information to the view to alert the user. I like to think of models in such a way that they can operate in a platform independent manner, or in other words.. I can drop the same models I use in a web app, into a commandline version of the same app, and the models should not have to be altered in any way. If for some reason, you have not satisfied a requirement for a model, I generally allow it to throw an exception (as Zend_Db_Table_* does) and handle it gracefully in the controller. Those are just some ideas to start kicking around. -ralph Justin Plock wrote: I'm trying to convert over an existing site over to using Zend_Db and Zend_Controller. I've got some error checking code in my Zend_Db_Table classes to make sure all of my required values are populated. I'm just asking in terms of a best practice, should this sort of error checking be moved up to the Controller so it is easier to communicate the error messages back to the user or do you think it should be tied to the Zend_Db_Table? Just looking for suggestions. Thanks. -- Matthew Weier O'Phinney PHP Developer| [EMAIL PROTECTED] Zend - The PHP Company | http://www.zend.com/
Re: [fw-general] Operating with file system: OO approach
I believe PEAR::VFS would work well for you, based on your description. http://pear.php.net/package/VFS On 3/31/07, Ivan Ruiz Gallego [EMAIL PROTECTED] wrote: Hello, I am looking for a class or a set of classes that allow an object-oriented operation with the file system. I am working now with SPL and I have also taken a look to PEAR, but I haven't so far found a comprehensive solution. As far as I know is such a library not included in Zend Framework. Here my questions: - Is the inclusion of such functionality planed within Zend Framework? - Does anyone know about such a library? Thanks. Best regards, Ivan. -- Loglan GmbH Ivan Ruiz Gallego Binzmühlestrasse 210 8050 Zürich Switzerland Office +41 44 310 19 20 Mobile +41 76 321 23 68 Net www.loglan.net
Re: [fw-general] Authentication in Mail Class
I wrote this a few weeks back and it seems to be working alright. It only supports AUTH LOGIN and AUTH PLAIN though. ?php require_once 'Zend/Mail/Transport/Smtp.php'; class My_Zend_Mail_Transport_Smtp_Auth extends Zend_Mail_Transport_Smtp { /[EMAIL PROTECTED] * Authentication types * @var string */ const LOGIN = 'LOGIN'; const PLAIN = 'PLAIN'; /[EMAIL PROTECTED]/ /** * @param string $username * @param string $password * @param string $method */ protected function authenticate($username, $password, $method = self::PLAIN) { switch($method) { case self::LOGIN: $this-authenticateLogin($username, $password); break; case self::PLAIN: $this-authenticatePlain($username, $password); break; } } /** * @param string $username * @param string $password * @throws Zend_Mail_Transport_Exception */ protected function authenticateLogin($username, $password) { $this-_send('AUTH LOGIN'); try { $this-_expect(334); } catch(Zend_Mail_Transport_Exception $e) { if(substr($e-getMessage(), 0, 3) == 503) { return; } throw $e; } $this-_send(base64_encode($username)); $this-_expect(334); $this-_send(base64_encode($password)); $this-_expect(235); } /** * @param string $username * @param string $password * @throws Zend_Mail_Transport_Exception */ protected function authenticatePlain($username, $password) { $this-_send('AUTH PLAIN'); try { $this-_expect(334); } catch(Zend_Mail_Transport_Exception $e) { if(substr($e-getMessage(), 0, 3) == 503) { return; } throw $e; } $this-_send(base64_encode(chr(0) . $username . chr(0) . $password)); $this-_expect(235); } } On 1/31/07, Sanjay Aggarwal [EMAIL PROTECTED] wrote: Right Now SMTP authentication is not there in the mail class. Is there anyone who has implemented SMTP authentication with Zend Framework any how? If so - do let me know asap. That will be a great help for us. Regards, Sanjay Aggarwal
Re: [fw-general] Zend_Db_Table is not a base for a model in MVC
The problem still remains that you can't call a derived classes static method in the base class.abstract class ActiveRecord { abstract static public function getTable(); static public function find() { echo self::getTable(); }}class Person extends ActiveRecord { static public function getTable() { return __CLASS__; }}Person::find();Fatal error: Cannot call abstract method ActiveRecord::getTable() in /home/jhendric/test.php on line 7 Call Stack: 0.0004 40688 1. {main}() /home/jhendric/test.php:0 0.0005 40688 2. ActiveRecord::find() /home/jhendric/test.php:20On 9/28/06, Matthew Weier O'Phinney [EMAIL PROTECTED] wrote: -- Davey Shafik [EMAIL PROTECTED] wrote(on Thursday, 28 September 2006, 10:20 AM -0400): And that'll teach me to jump in on a conversation :) What about implementing an interface which specifies a getTable() method, then don't implement it in an Abstract AR class. That way when you extend, you write in a: function getTable() { return __CLASS__; } or you can even do: function getTable() { return Somethingcompletelydifferent; } I dislike this idea, I prefer just to instantiate the AR class and use it as an object :)This type of solution was discussed at one point. I believe it wasrejected because many felt it added what could be construed as one steptoo many in development. Instead of simply: class MyTable extends Zend_Db_Table {}the developer now has to do:class MyTable extends Zend_Db_Table{public static function getTable(){return __CLASS__; }}Admittedly not a lot of code, but it's another vector for introducingerrors.I'm not exactly sure where my own preference lies, personally. On Sep 28, 2006, at 10:03 AM, Pavel Shevaev wrote: On 9/28/06, Davey Shafik [EMAIL PROTECTED] wrote: Uh __CLASS__ Not really, here's how it all started http://www.sitepoint.com/forums/showthread.php?t=334377--Matthew Weier O'Phinney PHP Developer| [EMAIL PROTECTED]Zend - The PHP Company | http://www.zend.com/