使用 newEntity 时 Cake 3 博客教程错误

Cake 3 Blog Tutorial Error While using newEntity

这是发生的错误: Unable to find table class for current entity

这里是文章控制器的添加方法

public function add()
{
    $article = $this->Articles->newEntity();
    if ($this->request->is('post')) {
        $article = $this->Articles->patchEntity($article, $this->request->data);
        if ($this->Articles->save($article)) {
            $this->Flash->success(__('Your article has been saved.'));
            return $this->redirect(['action' => 'index']);
        }
        $this->Flash->error(__('Unable to add your article.'));
    }
    $this->set('article', $article);
}

这是add.ctp

<h1>Add Article</h1>
<?php
    echo $this->Form->create($article);
    echo $this->Form->input('title');
    echo $this->Form->input('body', ['rows' => '3']);
    echo $this->Form->button(__('Save Article'));
    echo $this->Form->end();
?>

您需要升级 CakePHP 3 的安装。您遇到的是在发布第一个 Releseas Candidate 后早期出现的错误。要更新您的安装 运行:

composer update

在 composer.json 文件所在的应用程序的根目录中。

问题出在实体上! ,我只是创建了一个像这样的实体文件:

<?php
namespace App\Model\Entity;

use Cake\ORM\Entity;

/**
 * User Entity.
 */
class Article extends Entity
{

}