首页 \ 问答 \ ZF2:Zend Framework 2.3.0:致命错误:找不到类IndexController(ZF2: Zend Framework 2.3.0: Fatal Error: class IndexController not found)

ZF2:Zend Framework 2.3.0:致命错误:找不到类IndexController(ZF2: Zend Framework 2.3.0: Fatal Error: class IndexController not found)

我正在通过构建教程应用程序来研究Zend Framework。 我已经检查过我的代码几次,将它与本书的源代码进行比较。

我无法提出解决方案或解释为什么会出现这种错误。 谁能帮我吗?

Fatal error: Class 'Wall\Controller\IndexController' not found in C:\xampp\htdocs\Connect\client\vendor\zendframework\zendframework\library\Zend\ServiceManager\AbstractPluginManager.php on line 170

Call Stack
#   Time    Memory  Function

1   0.0010  138824  {main}( )   ..\index.php:0
2   0.1250  4071920 Zend\Mvc\Application->run( )    ..\index.php:12
3   0.1260  4090064 Zend\EventManager\EventManager->trigger( )  ..\Application.php:316
4   0.1260  4090072 Zend\EventManager\EventManager->triggerListeners( ) ..\EventManager.php:207
5   0.1270  4091280 call_user_func ( )  ..\EventManager.php:468
6   0.1270  4091568 Zend\Mvc\DispatchListener->onDispatch( )    ..\EventManager.php:468
7   0.1270  4091752 Zend\Mvc\Controller\ControllerManager->get( )   ..\DispatchListener.php:97
8   0.1270  4091936 Zend\ServiceManager\AbstractPluginManager->get( )   ..\ControllerManager.php:137
9   0.1270  4091904 Zend\ServiceManager\ServiceManager->get( )  ..\AbstractPluginManager.php:103
10  0.1270  4092584 Zend\ServiceManager\ServiceManager->create( )   ..\ServiceManager.php:504
11  0.1270  4092728 Zend\ServiceManager\ServiceManager->doCreate( ) ..\ServiceManager.php:572
12  0.1270  4092816 Zend\ServiceManager\AbstractPluginManager->createFromInvokable( )   ..\ServiceManager.php:616

module.config.php

return array(
    'router' => array(
        'routes' => array(
            'wall' => array(
                'type' => 'Zend\Mvc\Router\Http\Segment',
                'options' => array(
                    'route' => '/:username',
                    'constraints' => array(
                        'username' => '\w+'
                    ),
                    'defaults' => array(
                        'controller' => 'Wall\Controller\Index',
                        'action'     => 'index',
                    ),
                ),
            ),
        ),
    ),
    'controllers' => array(
        'invokables' => array(
            'Wall\Controller\Index' => 'Wall\Controller\IndexController',
        ),
    ),
    'view_manager' => array(
        'template_path_stack' => array(
            __DIR__ . '/../view',
        ),
    ),
);

module.php

namespace Wall;

use Zend\Mvc\ModuleRouteListener;
use Zend\Mvc\MvcEvent;

class Module
{
    public function getConfig()
    {
        return include __DIR__ . '/config/module.config.php';
    }

    public function getAutoloaderConfig()
    {
        return array(
            'Zend\Loader\StandardAutoloader' => array(
                'namespaces' => array(
                    __NAMESPACE__ => __DIR__ . '/src/' , __NAMESPACE__
                ),
            ),
        );
    }
}

IndexController.php

namespace Wall\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\Stdlib\Hydrator\ClassMethods;
use Users\Entity\User;
use Api\Client\ApiClient as ApiClient;

class IndexController extends AbstractActionController
{
    public function indexAction()
    {
        $viewData = array();

        $username = $this->params()->fromRoute('username');
        $this->layout()->username = $username;

        $response = ApiClient::getWall($username);

        if ($response !== FALSE) {
            $hydrator = new ClassMethods();

            $user = $hydrator->hydrate($response, new User());
        } else {
            $this->getResponse()->setStatusCode(404);
            return;
        }

        $viewData['profileData'] = $user;

        return $viewData;
    }
}

I'm studying the Zend Framework by building a tutorial application. I've checked my code a couple of times comparing it to the source code of the book.

I can't come up with a solution or explanation as to why this error keeps occuring. Can anyone help me out?

Fatal error: Class 'Wall\Controller\IndexController' not found in C:\xampp\htdocs\Connect\client\vendor\zendframework\zendframework\library\Zend\ServiceManager\AbstractPluginManager.php on line 170

Call Stack
#   Time    Memory  Function

1   0.0010  138824  {main}( )   ..\index.php:0
2   0.1250  4071920 Zend\Mvc\Application->run( )    ..\index.php:12
3   0.1260  4090064 Zend\EventManager\EventManager->trigger( )  ..\Application.php:316
4   0.1260  4090072 Zend\EventManager\EventManager->triggerListeners( ) ..\EventManager.php:207
5   0.1270  4091280 call_user_func ( )  ..\EventManager.php:468
6   0.1270  4091568 Zend\Mvc\DispatchListener->onDispatch( )    ..\EventManager.php:468
7   0.1270  4091752 Zend\Mvc\Controller\ControllerManager->get( )   ..\DispatchListener.php:97
8   0.1270  4091936 Zend\ServiceManager\AbstractPluginManager->get( )   ..\ControllerManager.php:137
9   0.1270  4091904 Zend\ServiceManager\ServiceManager->get( )  ..\AbstractPluginManager.php:103
10  0.1270  4092584 Zend\ServiceManager\ServiceManager->create( )   ..\ServiceManager.php:504
11  0.1270  4092728 Zend\ServiceManager\ServiceManager->doCreate( ) ..\ServiceManager.php:572
12  0.1270  4092816 Zend\ServiceManager\AbstractPluginManager->createFromInvokable( )   ..\ServiceManager.php:616

module.config.php

return array(
    'router' => array(
        'routes' => array(
            'wall' => array(
                'type' => 'Zend\Mvc\Router\Http\Segment',
                'options' => array(
                    'route' => '/:username',
                    'constraints' => array(
                        'username' => '\w+'
                    ),
                    'defaults' => array(
                        'controller' => 'Wall\Controller\Index',
                        'action'     => 'index',
                    ),
                ),
            ),
        ),
    ),
    'controllers' => array(
        'invokables' => array(
            'Wall\Controller\Index' => 'Wall\Controller\IndexController',
        ),
    ),
    'view_manager' => array(
        'template_path_stack' => array(
            __DIR__ . '/../view',
        ),
    ),
);

module.php

namespace Wall;

use Zend\Mvc\ModuleRouteListener;
use Zend\Mvc\MvcEvent;

class Module
{
    public function getConfig()
    {
        return include __DIR__ . '/config/module.config.php';
    }

    public function getAutoloaderConfig()
    {
        return array(
            'Zend\Loader\StandardAutoloader' => array(
                'namespaces' => array(
                    __NAMESPACE__ => __DIR__ . '/src/' , __NAMESPACE__
                ),
            ),
        );
    }
}

IndexController.php

namespace Wall\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\Stdlib\Hydrator\ClassMethods;
use Users\Entity\User;
use Api\Client\ApiClient as ApiClient;

class IndexController extends AbstractActionController
{
    public function indexAction()
    {
        $viewData = array();

        $username = $this->params()->fromRoute('username');
        $this->layout()->username = $username;

        $response = ApiClient::getWall($username);

        if ($response !== FALSE) {
            $hydrator = new ClassMethods();

            $user = $hydrator->hydrate($response, new User());
        } else {
            $this->getResponse()->setStatusCode(404);
            return;
        }

        $viewData['profileData'] = $user;

        return $viewData;
    }
}

原文:https://stackoverflow.com/questions/22682424
更新时间:2022-05-10 14:05

最满意答案

选项1:在源头修复问题。 无论您哪里获取这些文件,请修复该文件以使文件具有扩展名。

选项2:分配扩展名:

Sub assign_extension()
Dim f
Dim FSO As Object
Const ext as String = ".txt"                       '### MODIFY AS NEEDED
Const path As String = "C:\Path\To Your Files\"    '### MODIFY AS NEEDED
Set FSO = CreateObject("Scripting.FileSystemObject")
f = Dir(path)
Do

    Debug.Print f
    If FSO.GetExtensionName(path & f) = vbNullString Then
        Name (path & f) As (path & f & ext)
    End If

    f = Dir()
Loop While f <> vbNullString

End Sub

Option 1: Fix the problem at the source. Wherever you're getting these files from, fix that so that the files will have an extension.

Option 2: Assign an extension:

Sub assign_extension()
Dim f
Dim FSO As Object
Const ext as String = ".txt"                       '### MODIFY AS NEEDED
Const path As String = "C:\Path\To Your Files\"    '### MODIFY AS NEEDED
Set FSO = CreateObject("Scripting.FileSystemObject")
f = Dir(path)
Do

    Debug.Print f
    If FSO.GetExtensionName(path & f) = vbNullString Then
        Name (path & f) As (path & f & ext)
    End If

    f = Dir()
Loop While f <> vbNullString

End Sub

相关问答

更多
  • 如果您已经使用了很多Linux系统(或其他传统的类UNIX系统,如BSD),您可能会注意到许多类型的文件缺少扩展,包括可执行文件。 Linux和其他* nix系统倾向于依赖文件扩展名以外的方法来确定文件的类型(例如开头的魔术代码,许多文件格式都有)。 如果您的系统具有“文件”实用程序(在Windows以外的大多数操作系统上预先安装),则可以对此进行测试。 命名文件README等的做法,没有扩展,可以追溯到很久以前。 在控制台上工作时,您倾向于通过执行类似program ./path/to/file类的操作来 ...
  • 在这里回答https://stackoverflow.com/a/16998463/7527037 以.scss扩展名打开相应的文件。 从顶部的菜单中,转到View> Syntax> [可选:以当前分机打开所有...] > CSS Answered here https://stackoverflow.com/a/16998463/7527037 Open the corresponding file with .scss extension. From the menu at the top, goto ...
  • 我将我的java代码更新为以下内容: 以前的代码 dos.writeBytes("Content-Disposition: form-data; name= \"uploaded_file\";filename="+ fileName + "" + lineEnd); 更新的代码 dos.writeBytes("Content-Disposition: form-data; name= \"uploaded_file\";filename="+ fileName.replace(" ", "_") + "" ...
  • 即使内部是类似XML的结构化文件,它们也应该是XSD。 你可以用usx解析它,就像一个xml。 唯一的区别是每个元素名称都以“xs:”开头,并且元素名称。 they should be XSD even if the inside is an XML-like structured file. You can ususally parse it like an xml. the only difference is that each element name will begin with "xs:" f ...
  • Desktop.open()启动与文件扩展名关联的应用程序。 Desktop.open() launches the application associated with the extension of the file.
  • 看起来你正在使用C,为什么C ++标签呢? 是允许的吗? C ++中有简单易用的类来操作文件。 但是你肯定需要在文件名( input_path )中包含扩展名,因为同一目录中可以存在多个具有相同名称和不同扩展名的文件,那么应该打开哪一个? 编辑:应该知道文件扩展名(特别是在类UNIX操作系统中)只是一个“帮助”的东西,它们并不是真正必要的。 例如,您可以拥有一个包含C ++代码但没有.cpp扩展名的文件,例如它的名称只有foo而没有扩展名(或者甚至有像foo.bar这样的疯狂扩展名)。 你仍然可以使用g + ...
  • 选项1:在源头修复问题。 无论您从哪里获取这些文件,请修复该文件以使文件具有扩展名。 选项2:分配扩展名: Sub assign_extension() Dim f Dim FSO As Object Const ext as String = ".txt" '### MODIFY AS NEEDED Const path As String = "C:\Path\To Your Files\" '### MODIFY AS NEEDED Set FSO = ...
  • 最好的方法是使用带有通配符的“列表文件夹”(使用“模式”输入)来获取文件数组。 然后你必须逐个删除文件。 The best way is to use "List Folder" with wild-cards (using "pattern" input) to get an array of files. Then you have to delete files one by one.
  • 解决了。 它适用于PowerShell Studio Solved. It is for PowerShell Studio
  • 我想知道你是否可以用宏来做到这一点。 我最好的建议是安装这个插件: https://visualstudiogallery.msdn.microsoft.com/d3fbf133-e51b-41a2-b86f-9560a96ff62b 应该可以有一个宏来做到这一点。 我建议您考虑如何做到这一点,因为打开200多个文件可能会使Visual Studio无法响应! 另外! (不,我不为他们工作) 获取Resharper的副本并将其设置为分析整个解决方案的错误,我相信它也会显示.cshtml问题。 I wonde ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。