我正在通过构建教程应用程序来研究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;
}
}
答案 0 :(得分:0)
错误很可能在自动加载配置中
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' , __NAMESPACE__
// ^-- that should be a DOT .
),
),
);
}