1
我正在通過構建教程應用程序來學習Zend Framework。 我已經檢查過我的代碼幾次,並將其與本書的源代碼 進行比較。ZF2:Zend Framework 2.3.0:致命錯誤:class IndexController not found
我不能想出解決方案或解釋爲什麼 此錯誤不斷髮生。誰能幫我嗎?
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;
}
}
謝謝,但它沒有解決問題。 – murtho
配置緩存啓用? – Sam
可能已經做到了,只是休息一下,現在它正在按照它應該的方式工作。 – murtho