나는 같은 젠드 프레임 워크 2 튜토리얼 프로젝트의 오류,"서비스를 확인할 수 없습니다" "공장에, 당신은 당신이 구성 중에 제공 확신?" 젠드 프레임 워크에서 2
Unable to resolve service "Album\Controller\AlbumController" to a factory; are you certain you provided it during configuration?
내 Module.php
namespace Album;
use Zend\ModuleManager\Feature\ConfigProviderInterface;
class Module implements ConfigProviderInterface
{
public function getConfig()
{
return include __DIR__ . '/../config/module.config.php';
}
public function getServiceConfig()
{
return [
'factories' => [
Model\AlbumTable::class => function($container) {
$tableGateway = $container->get(Model\AlbumTableGateway::class);
return new Model\AlbumTable($tableGateway);
},
Model\AlbumTableGateway::class => function ($container) {
$dbAdapter = $container->get(AdapterInterface::class);
$resultSetPrototype = new ResultSet();
$resultSetPrototype->setArrayObjectPrototype(new Model\Album());
return new TableGateway('album', $dbAdapter, null, $resultSetPrototype);
},
],
];
}
public function getControllerConfig()
{
return [
'factories' => [
Controller\AlbumController::class => function($container) {
return new Controller\AlbumController(
$container->get(Model\AlbumTable::class)
);
},
],
];
}
}
그리고 내 module.config.php이기 때문에 무엇입니까;
namespace Album;
use Zend\Router\Http\Segment;
//use Zend\ServiceManager\Factory\InvokableFactory;
return [
'controllers' => [
'factories' => [
Controller\AlbumController::class => InvokableFactory::class,
],
],
'router' => [
'routes' => [
'album' => [
'type' => Segment::class,
'options' => [
'route' => '/album[/:action[/:id]]',
'constraints' => [
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
],
'defaults' => [
'controller' => Controller\AlbumController::class,
'action' => 'index',
],
],
],
],
],
'view_manager' => [
'template_path_stack' => [
'album' => __DIR__ . '/../view',
],
],
];
저는 Zend Framework에서 매우 새롭습니다. 내가 뭘 잘못하고 있는지 알아낼 수 없습니다. 더 많은 코드가 필요한지 언급하십시오.
당신은 "컨트롤러 \ AlbumController :: 클래스"에 대한 두 개의 공장을 정의
나는 그것을 가지고, 그 문제를 해결하지만, 새로운 서비스 "앨범 \를 해결할 수없는 **입니다 예 AdapterInterface "를 팩토리에; 당신은 당신이 구성 중에 제공? ** 지금 당신이 더 많은 나에게 좀 도와주세요 수있는 특정입니까? –
config/modules.config.php 또는 config/application.config.php의 "modules"키에 zend \ db가 있습니까? –
은 또한 당신이 필요합니다 "젠드 \ DB \ 어댑터 \ AdapterInterface를 사용합니다" in Module.php -> 이것은 당신의 문제로 보인다! –