1

Version_DefaultComponentForm.php

namespace ComponentManagement\Form;
class Version_DefaultComponentForm extends VersionForm {
    public function __construct($name = null) {

组件管理控制器.php

namespace ComponentManagement\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use ComponentManagement\Form;
use ComponentManagement\Model\Component;

    class ComponentManagementController extends AbstractActionController {
        protected $albumTable;
        public function indexAction() {
            $componentForm = new Form\ComponentForm();
            $versionForm = new Form\VersionForm();
            $version_DefaultComponentForm = new Form\Version_DefaultComponentForm();

我收到了这个错误:

致命错误:第 15 行的 D:\WEB\xampp\htdocs_zend\module\ComponentManagement\src\ComponentManagement\Controller\ComponentManagementController.php 中找不到类 'ComponentManagement\Form\Version_DefaultComponentForm'

自己找不到任何错误...谁能告诉我为什么?使用 php 5.4.7 和 zend 2.0

不知道为什么,但它现在可以正常工作。

namespace ComponentManagement\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use ComponentManagement\Form;
use ComponentManagement\Model\Component;

class ComponentManagementController extends AbstractActionController {

    public function indexAction() {
        $componentForm = new Form\ComponentForm();
        $versionForm = new Form\VersionForm();

        $request = $this->getRequest();
        if ($request->isPost()) {
            $component = new Component();
            $componentForm->setInputFilter($component->getInputFilter());
            $componentForm->setData($request->getPost());

            if ($componentForm->isValid()) {

            }
        }
        return array('forms' => array(
                'ComponentForm' => $componentForm,
                'VersionForm' => $versionForm,
            )
        );
    }
4

1 回答 1

1

http://framework.zend.com/manual/2.0/en/modules/zend.loader.standard-autoloader.html

Zend\Loader\StandardAutoloader 被设计为符合 PSR-0 的自动加载器。它假设命名空间+类名到文件系统的 1:1 映射,其中命名空间分隔符和下划线被转换为目录分隔符。:P

于 2013-01-09T02:33:53.080 回答