zend-framework

zend framework losing session

元气小坏坏 提交于 2019-12-21 05:19:21
问题 I am trying to implement a Flash uploader in my Zend framework application but I am having problems with the session. The Flash does not send any cookie headers and this is why the session is lost. I am trying to send the sessionId as a post param and in my bootstrap file I added a session_id($_POST['session_id]) but this doenst seem to work. I am using a MySQL table as session storage I tryed to debug the error and as far as I see, the session_id is set, and the storage returns the corect

Why the Service Locator is a Anti-Pattern in the following example?

时光毁灭记忆、已成空白 提交于 2019-12-21 05:16:22
问题 I have a MVC application with a Domain Model well defined, with entities, repositories and a service layer. To avoid having to instantiate my service classes inside my controllers, and thus, mess my controllers with logic that does not suit they, I created a helper that acts as a sort of Service Locator, but after reading a bit, I realized that many devs: http://blog.tfnico.com/2011/04/dreaded-service-locator-pattern.html http://blog.ploeh.dk/2010/02/03/ServiceLocatorIsAnAntiPattern.aspx http

htaccess block access to directory but allow access to files

与世无争的帅哥 提交于 2019-12-21 05:07:32
问题 I have such situation. I'm developing application in Zend Framework and htaccess pointing every request to index.php. If some file or directory exists on the request path then htaccess allow access to this files like css, js, images etc... Now I have for example such link: example.com/profile/martin-slicker-i231 With Zend Router it points to controller account and action viewprofile. I want to add some avatart for my users and I created directory in public folder (so the images would be

Youtube API - How to limit results for pagination?

[亡魂溺海] 提交于 2019-12-21 04:51:02
问题 I want to grab a user's uploads (ie: BBC) and limit the output to 10 per page. Whilst I can use the following URL: http://gdata.youtube.com/feeds/api/users/bbc/uploads/?start-index=1&max-results=10 The above works okay. I want to use the query method instead: The Zend Framework docs: http://framework.zend.com/manual/en/zend.gdata.youtube.html State that I can retrieve videos uploaded by a user, but ideally I want to use the query method to limit the results for a pagination. The query method

how to calculate a difference between two Zend_Date objects, in months

送分小仙女□ 提交于 2019-12-21 04:39:06
问题 I have two objects of Zend_Date class and I want to calculate the difference between them in full calendar months.. How can I do this? <?php $d1 = new Zend_Date('1 Jan 2008'); $d2 = new Zend_Date('1 Feb 2010'); $months = $d1->sub($d2)->get(Zend_Date::MONTH); assert($months == -25); // failure here Thanks in advance! 回答1: If I read the docs correctly, there's no implemented functionality for getting difference between 2 dates in seconds/minutes/.../months/years, so you'll need to calculate it

ZF2: how do I get ServiceManager instance from inside the custom class

流过昼夜 提交于 2019-12-21 04:25:26
问题 I'm having trouble figuring out how to get ServiceManager instance from inside the custom class. Inside the controller it's easy: $this->getServiceLocator()->get('My\CustomLogger')->log(5, 'my message'); Now, I created a few independent classes and I need to retrieve Zend\Log instance inside that class. In zend framework v.1 I did it through static call: Zend_Registry::get('myCustomLogger'); How can I retrieve the My\CustomLogger in ZF2? 回答1: Make your custom class implement the

Zend Forms - populate() and setDefaults()

☆樱花仙子☆ 提交于 2019-12-21 04:15:11
问题 Let's say I have a form that collects a first name and a last name: $first_name = new Zend_Form_Element_Text('first_name'); $first_name->setLabel("First Name") ->setRequired(true); $last_name = new Zend_Form_Element_Text('last_name'); $last_name->setLabel("Last Name") ->setRequired(true); $form = new Zend_Form(); $form->addElement($first_name) ->addElement($last_name) If I want to use the "populate($data)" or the "setDefaults($data)" method on the form, how does the array need to be organized

Event-driven CMS - advantages and disadvantages

房东的猫 提交于 2019-12-21 03:52:35
问题 I'm trying to identify some of the pros and cons of having a CMS that is event driven. Event driven is not uncommon. You see it in many scripting languages like Actionscript, javascript, jquery that involve a client. How about in a CMS where the events and their responses happen on the server. What advantages or disadvantages might this approach have, and what other approaches are there that people may prefer more. P.S. Please note that I use Actionscript, JQ, and JS as an example only. You

How to destroy Zend_Session_Namespace without session_destroy

送分小仙女□ 提交于 2019-12-21 03:51:21
问题 I store a couple of value in a temporary session using: $job = new Zend_Session_Namespace('application'); How would I destroy only the session application without clearing all sessions. 回答1: To remove a value from a session, use PHP's unset() function on the object property. Let's say $job has a property 'username' like so : $job = new Zend_Session_Namespace('application'); $job->username = 'test'; To remove username from the session just do : unset($job->username); To remove the whole

Zend Framework Modules can't find/load Models

微笑、不失礼 提交于 2019-12-21 02:56:18
问题 For some frustrating reason, I configured some Modules, which seemed to work fine, However I cannot load a Modules Models. If I move the Models to the Default they load, but I just can't get the Framework to find them locally.. Example: My Modules Directory is: application\modules\books\models\books.php (books is my Model) class Application_Module_Books_Model_Books extends Zend_Db_Table_Abstract {} I also tried.. Books_Model_Books, Model_Books, books, Modules_.. you name it I tried it :) My