尝试执行AutoloaderProviderInterface
如下:
<?php
namespace Document;
use Zend\Db\ResultSet\ResultSet;
use Zend\Db\TableGateway\TableGateway;
use Zend\ModuleManager\Feature\ConfigProviderInterface;
use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
class Module implements ConfigProviderInterface, AutoloaderProviderInterface
{
public function getConfig()
{
return include __DIR__ . '/../config/module.config.php';
}
public function getServiceConfig()
{
return [
'factories' => [
Model\DocumentTable::class => function($container) {
$tableGateway = $container->get(Model\DocumentTableGateway::class);
return new Model\DocumentTable($tableGateway);
},
Model\DocumentTableGateway::class => function ($container) {
$dbAdapter = $container->get(AdapterInterface::class);
$resultSetPrototype = new ResultSet();
$resultSetPrototype->setArrayObjectPrototype(new Model\Document());
return new TableGateway('document', $dbAdapter, null, $resultSetPrototype);
},
],
];
}
public function getControllerConfig()
{
return [
'factories' => [
Controller\DocumentController::class => function($container) {
return new Controller\DocumentController(
$container->get(Model\DocumentTable::class)
);
},
],
];
}
public function getAutoloaderConfig()
{
return [
'Zend\Loader\StandardAutoloader' => [
'namespaces' => [
__NAMESPACE__ => __DIR__,
],
],
];
}
}
您可能需要更改行中的路径__NAMESPACE__ => __DIR__
,具体取决于您使用的目录结构和Module.php
文件的位置。