Zend 세션 문제 (초보자)
-
06-09-2019 - |
문제
나는 Zend Am을 가르치고 있으며 내 세션을 사용하여 View 도우미 행동을 호출하는 데 문제가 있습니다.
내 컨트롤러 :
<?php
class SessionController extends Zend_Controller_Action
{
protected $session;
public function init() //Like a constructor
{
$this->_helper->viewRenderer->setNoRender(); // Will not automatically go to views/Session
$this->_helper->getHelper('layout')->disableLayout(); // Will not load the layout
}
public function preDispatch() //Invokes code before rendering. Good for sessions/cookies etc.
{
$this->session = new Zend_Session_Namespace(); //Create session
if(!$this->session->__isset('view'))
{
$this->session->view = $this->view; //if the session doesn't exist, make it's view default
}
}
public function printthingAction()
{
echo $this->session->view->tabbedbox($this->getRequest()->getParam('textme'));
}
}
?>
내 뷰 도우미
<?php
class App_View_Helper_Tabbedbox extends Zend_View_Helper_Abstract
{
public $wordsauce = "";
public function tabbedbox($message = "")
{
$this->wordsauce .= $message;
return '<p>' . $this->wordsauce . "</p>";
}
}
?>
내 견해 :
<p>I GOT TO THE INDEX VIEW</p>
<input id='textme' type='input'/>
<input id='theButton' type='submit'/>
<div id="putstuffin"></div>
<script type="text/javascript">
$(function()
{
$("#theButton").click(function()
{
$.post(
"session/printthing",
{'textme' : $("#textme").val()},
function(response)
{
$("#putstuffin").append(response);
});
});
});
</script>
처음으로 Button을 클릭하면 효과가 있으며 예상처럼 내 말을 추가합니다. 그러나 매번 후에는이 오류 메시지를 제공합니다.
경고 : call_user_func_array () [function.call-user-func-array] : 첫 번째 인수는 유효한 콜백이 될 것으로 예상됩니다. Abstract.php on 341
Zendcasts.com 비디오를 거의 라인에 복사했지만 여전히 작동하지 않습니다. 내 세션이 파괴되고있는 것 같습니다. 무슨 일이 일어나고 있는지 말해 줄 수있는 사람에게 영원히 감사 할 것입니다.
해결책
세션에 객체를 저장하면 실제로 저장하고 있습니다. 직렬화 된 표현 그것의. __php_incomplete_class :: tabbedbox는 후속 요청에서 PHP가 app_view_helper_tabbedbox가 무엇인지 잊어 버렸기 때문에 발생합니다.
해결책 : zend_session :: start ()가 호출되기 전에 App_View_Helper_Tabbedbox 클래스 파일을 포함시켜야합니다.
그리고이를 수행하는 가장 좋은 방법은 앱을 시작할 때 이것을 배치하는 것입니다.
require_once 'Zend/Loader.php';
Zend_Loader::registerAutoload();
제휴하지 않습니다 StackOverflow