ServiceNotFoundException in ZendFramework 2, Beispiel von Rob Allen
seit einigen wochen verfolge ich vor allem zf2Rob Allens 'Album' BeispielIch habe das Beispiel-DB-'zf2tutorial 'und die Beispiel-Tabelle-'album' erstellt, was gut funktioniert, wenn ich alle Elemente mit PHP-MySQL abrufe, also Probleme mit den Daten in der DB.
Meine local.php sieht so auscon fi g.autoload / local.php:
return array(
'db' => array
(
'driver' => "Pdo",
'dsn' => "mysql:dbname=zf2tutorial;hostname=localhost",
'username' => "user", //here I added my valid username
'password' => "password", //here I added my valid password
'driver_options' => array
(
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'"
),
),
);
Module.php ** module / Album / Model.php
<?php
namespace Album;
use Album\Model\AlbumTable;
class Module
{
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\ClassMapAutoloader' => array(
__DIR__ . '/autoload_classmap.php',
),
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
),
),
);
}
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
public function getServiceConfiguration()
{
return array(
'factories' => array(
'album-table' => function($sm) //also tried this 'Album\Model\AlbumTable' => function($sm)
{
$dbAdapter = $sm->get('db-adapter');//also tried this $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
$table = new AlbumTable($dbAdapter);
return $table;
},
),
);
}
}
Ich wollte nur überprüfen, ob das zf2turorial / album funktioniert oder nichtdiese poste hier in stackoverlow.
Der Fehler, den es wirft, ist:Zusätzliche Informationen: Zend \ ServiceManager \ Exception \ ServiceNotFoundException
File:
..\vendor\zendframework\zendframework\library\Zend\ServiceManager\ServiceManager.php:392
Message:
Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for Album\Model\AlbumTable
Ich habe auch das ZF2 Beta 5-Tutorial verfolgt, bin aber immer noch auf dieses Problem gestoßen. Falls jemand eine Lösung hat, teilen Sie uns dies bitte mit.
Vielen Dank