gpt4 book ai didi

找不到php命名空间类

转载 作者:行者123 更新时间:2023-12-04 16:56:30 25 4
gpt4 key购买 nike

Version_DefaultComponentForm.php

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

组件管理 Controller .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();

我收到此错误:

Fatal error: Class 'ComponentManagement\Form\Version_DefaultComponentForm' not found in D:\WEB\xampp\htdocs_zend\module\ComponentManagement\src\ComponentManagement\Controller\ComponentManagementController.php on line 15



我自己找不到任何错误......谁能告诉我为什么?使用 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,
)
);
}

最佳答案

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

Zend\Loader\StandardAutoloader is designed as a PSR-0-compliant autoloader. It assumes a 1:1 mapping of the namespace+classname to the filesystem, wherein namespace separators and underscores are translated to directory separators. :P

关于找不到php命名空间类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14208619/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com