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
最满意答案
选项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 ...
-
没有文件扩展名(No File Extension)[2021-12-30]
我将我的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(" ", "_") + "" ... -
XSD文件的文件扩展名(File Extension of XSD files)[2024-05-15]
即使内部是类似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 ... -
如何打开没有扩展名的文件(How to open file without extension)[2022-09-08]
Desktop.open()启动与文件扩展名关联的应用程序。 Desktop.open() launches the application associated with the extension of the file. -
文件是否需要在C / C ++中使用open()打开扩展名?(Does a file need an extension to be opened with open() in C/C++?)[2022-02-19]
看起来你正在使用C,为什么C ++标签呢? 是允许的吗? C ++中有简单易用的类来操作文件。 但是你肯定需要在文件名( input_path )中包含扩展名,因为同一目录中可以存在多个具有相同名称和不同扩展名的文件,那么应该打开哪一个? 编辑:应该知道文件扩展名(特别是在类UNIX操作系统中)只是一个“帮助”的东西,它们并不是真正必要的。 例如,您可以拥有一个包含C ++代码但没有.cpp扩展名的文件,例如它的名称只有foo而没有扩展名(或者甚至有像foo.bar这样的疯狂扩展名)。 你仍然可以使用g + ... -
打开没有扩展名的文件(Open files with no extension)[2023-07-31]
选项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
-
Visual Studio 2013 /打开特定扩展名的所有文件(Visual Studio 2013 / Open all files of a specific extension)[2023-05-05]
我想知道你是否可以用宏来做到这一点。 我最好的建议是安装这个插件: https://visualstudiogallery.msdn.microsoft.com/d3fbf133-e51b-41a2-b86f-9560a96ff62b 应该可以有一个宏来做到这一点。 我建议您考虑如何做到这一点,因为打开200多个文件可能会使Visual Studio无法响应! 另外! (不,我不为他们工作) 获取Resharper的副本并将其设置为分析整个解决方案的错误,我相信它也会显示.cshtml问题。 I wonde ...