Zend Framework Application Progress

Hold on Cowboy

This blog post is pretty old. Be careful with the information you find in here. It's likely dead, dying, or wildly inaccurate.

Today I learned from Zend Framework.

Redirecting visitors to their intended URI after login 

LoginForm.php … // Grabs the requested URI from the server and stores it in a hidden field $this->addElement(‘hidden’, ‘referrer’, array(‘value’ => $_SERVER[‘REQUEST_URI’])); …

Then after you complete authentication, send them to the referring URI if($form->getValue(‘referrer’)) $this->_redirect($form->getValue(‘referrer’)); $this->_redirect(‘index/index’);

Credits: http://stackoverflow.com/questions/1249274/redirect-to-previous-page-in-zend-framework


Throwing an error message 

This one is easy. You want to throw an error message with some meaning. throw new Zend_Exception(‘This is the error message’);


Saving data in Zend_Session 

You want to save some data in a session variable so you can access it other places in application. So in the Bootstrap.php file you would place Zend_Session::start();

To set the variable you would use $ns = new Zend_Session_Namespace(‘hello’); $ns->domain = “Hello World”; By using the namespace “hello” or whatever you want, then you can keep your variables separate from another part of the applicate that just might happen to name it’s variable “domain” as well.

To retrieve this fun filled variable. $ns = new Zend_Session_Namespace(‘hello’); print $ns->domain;

Did this help you out? It took me a few days to piece together all this information together, I hope this saves you some time (who knows, maybe the future me will be thankful I wrote this down). Let me know your thoughts. shanestillwell@gmail.com