的Zend框架的工作,我創建了側模型文件夾我的模塊src文件夾內的一個模式,我想用這個模型作爲服務,我調用的模型類Module.php配置,但是當我運行該應用程序時,它顯示錯誤ServiceNotFoundException。
Zend\ServiceManager\ServiceManager::createFromInvokable: failed retrieving "authdbservice(alias: AuthDbService)" via invokable class "Authentication\Model\AuthDb"; class does not exist
ZF2 ServiceNotFoundException的,如何解決我使用
這裏是我的module.php文件 類模塊實現AutoloaderProviderInterface,
ConfigProviderInterface, ServiceProviderInterface
{
/**
*
* {@inheritDoc}
* @see \Zend\ModuleManager\Feature\AutoloaderProviderInterface::getAutoloaderConfig()
*/
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\ClassMapAutoloader' => array(
__DIR__ . '/autoload_classmap.php',
),
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
),
),
);
}
/**
*
* {@inheritDoc}
* @see \Zend\ModuleManager\Feature\ConfigProviderInterface::getConfig()
*/
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
/**
*
* {@inheritDoc}
* @see \Zend\ModuleManager\Feature\ServiceProviderInterface::getServiceConfig()
*/
public function getServiceConfig()
{
return array(
'invokables' => array(
'AuthService' => 'Authentication\Service\AuthService',
'AuthDbService' => 'Authentication\DbService\AuthDb',
),
);
}
}
這裏是我authDb類
namespace Authentication\DbService;
use Doctrine\ORM\EntityManager;
use Authentication\Entity\User;
use Authentication\Form\RegisterForm;
class AuthDb {
protected $em;
protected function getEntityManger() {
if (null === $this->em) {
$this->em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
}
return $this->em;
}
public function submitNewUser() {
$form = new RegisterForm();
$form->get('submit')->setValue('Register');
$request = $this->getRequest();
if ($request->isPost()) {
$user = new User();
$form->setInputFilter($user->getInputFilter());
$form->setData($request->getPost());
if ($form->isValid()) {
$user->exchangeArray($form->getData());
$user->__set('password', md5($user->__get('password')));
$this->getEntityManager()->persist($user);
$this->getEntityManager()->flush();
return $this->redirect()->toRoute('auth', array('action' => 'login'));
} else {
return array('form' => $form, 'messages' => $form->getMessages());
}
}
}
}
我的目錄和文件結構
./Authentication
./Authentication/autoload_classmap.php
./Authentication/Module.php
./Authentication/view
./Authentication/view/authentication
./Authentication/view/authentication/auth
./Authentication/view/authentication/auth/register.phtml
./Authentication/view/authentication/auth/login.phtml
./Authentication/config
./Authentication/config/module.config.php
./Authentication/src
./Authentication/src/Authentication
./Authentication/src/Authentication/Service
./Authentication/src/Authentication/Service/AuthService.php
./Authentication/src/Authentication/Controller
./Authentication/src/Authentication/Controller/AuthController.php
./Authentication/src/Authentication/Model
./Authentication/src/Authentication/Model/AuthDbService.php
./Authentication/src/Authentication/Entity
./Authentication/src/Authentication/Entity/User.php
./Authentication/src/Authentication/Form
./Authentication/src/Authentication/Form/LoginForm.php
./Authentication/src/Authentication/Form/RegisterForm.php
我認爲這是小姐的配置理解爲我在這種情況下 任何想法解決這一問題?