php - Zend 加载程序插件加载程序例外

  显示原文与译文双语对照的内容
0 0

在使用 Zend 框架验证功能时,我遇到了以下错误:

Fatal error: Uncaught exception 'Zend_Loader_PluginLoader_Exception' 
 with message 'Plugin by name '0' was not found in the registry; used paths: Zend_Validate_: Zend/Validate/' 
 in/var/www/platform/lib/Zend/Loader/PluginLoader.php:406 
Stack trace:
#0/var/www/platform/lib/Zend/Filter/Input.php(1108): Zend_Loader_PluginLoader->load('0') 
#1/var/www/platform/lib/Zend/Filter/Input.php(1089): Zend_Filter_Input->_getFilterOrValidator('validate', Array) 
#2/var/www/platform/lib/Zend/Filter/Input.php(867): Zend_Filter_Input->_getValidator(Array) 
#3/var/www/platform/lib/Zend/Filter/Input.php(786): Zend_Filter_Input->_validate() 
#4/var/www/platform/lib/Zend/Filter/Input.php(414): Zend_Filter_Input->_process() 
#5/var/www/platform/app/controllers/admin/MatchfindersubjectsController.php(90): Zend_Filter_Input->hasMissing() 
#6/var/www/platform/lib/Zend/Controller/Action.php(513): Admin_MatchFinderSubjectsController->addAction() 
#7/var/www/platform/lib/Zend/Controller/Dispatcher/Standard.php(289): Zend_C in/var/www/platform/lib/Zend/Loader/PluginLoader.php on line 406

使用这里代码时:

/**
 * Handle the index
 *
 * @return void
 */
public function addAction()
{
 $filters = [
 'subject' => 'StringTrim',
 'gender' => 'Digits'
 ];
 $validators = [
 'subject' => [
 'presence' => 'required'
 ],
 'gender' => [
 new Zend_Validate_Int(),
 [ 'Between' => 0, 2 ],
 'Digits'
 ]
 ];
 $data = new Zend_Filter_Input( $filters, $validators );
 $data->setData( $_POST );
 $x = $data->hasMissing();
 die( var_export( $data ) );
}

我似乎找不到:

  1. 为什么要加载'0"'
  2. 如何使它正常工作 !
时间:原作者:1个回答

0 0

问题是你的验证器。

尝试更改

[ 'Between' => 0, 2 ],

new Zend_Validate_Between(['min' => 0, 'max' => 2]),
原作者:
...