所以我的問題是在Zend Framework 2中使用Doctrine 2.我正確安裝了Doctrine,並且當我嘗試在控制器中使用它時,出現此錯誤:PluginManager :: get無法爲getObjectManager獲取或創建實例
C:\wamp2\www\zf2\vendor\zendframework\zendframework\library\Zend\ServiceManager\ServiceManager.php:518
這:
Zend\Mvc\Controller\PluginManager::get was unable to fetch or create an instance for getObjectManager
這是我的控制器:
class BlogController extends AbstractActionController
{
public function blogAction()
{
$article = $this->getObjectManager()->getRepository('\Application\Entity\Article')->findAll();
return new ViewModel(array('article' => $article));
}
}
這是我的觀點:
<?php if (isset($article)) : ?>
<?php foreach($article as $articles): ?>
<div class="col-lg-12 text-center">
<img class="img-responsive img-border img-full" src="" alt="">
<h2><?php echo $articles->getTitle(); ?>
<br>
<small><?php echo $articles->getDate(); ?></small>
</h2>
<p><?php echo $articles->getContent(); ?></p>
<a href="<?php echo $this->url('article') ?>" class="btn btn-default btn-lg">Read More</a>
<hr>
</div>
<?php endforeach; ?>
<?php endif; ?>
對於我的配置遵循了這一tutorial
Thnx兄弟,是的,我很匆忙,我沒有看到這個功能 – Mohammadov