我收到提示:Zf的3個介紹事務及的ServiceManager
Fatal error: Class Blog\Factory\ListControllerFactory contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Zend\ServiceManager\Factory\FactoryInterface::__invoke) in /d0/home/kgendig/www/Zend/module/Blog/src/Blog/Factory/ListControllerFactory.php on line 28
我做的所有 https://framework.zend.com/manual/2.4/en/in-depth-guide/services-and-servicemanager.html
我有什麼改變,我zend_version();是2.6.0
<?php
// Filename: /module/Blog/src/Blog/Factory/ListControllerFactory.php
namespace Blog\Factory;
use Blog\Controller\ListController;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
class ListControllerFactory implements FactoryInterface
{
/**
* Create service
*
* @param ServiceLocatorInterface $serviceLocator
*
* @return mixed
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$realServiceLocator = $serviceLocator->getServiceLocator();
$postService = $realServiceLocator->get('Blog\Service\PostServiceInterface');
return new ListController($postService);
}
}
請給你的'ListControllerFactory.php',如果你不給你的代碼,沒有人能告訴你什麼是錯的。然後你正在談論ZF3,但給出了一個ZF2.4手冊的鏈接,並有一個2.6版本。與ZF2或ZF3一起工作,但不要將沒有設計成一起工作的部件...... –
好吧,我把它粘貼到我的第一個音符 – kgendig