为什么在我使用 cakephp 4 时找不到 table?

why does the table is not being found when i'm using cakephp 4?

我正在使用本周发布的 CakePHP 4,我试图实现一个注册表单,但是当我提交表单时出现此错误

 public function register()
{
    if($this->request->is('post')){
        $userTable = TableRegistry::getTableLocator()->get('Users');
        $user = $userTable->newEntity();

        $hasher = new DefaultPasswordHasher();
        $myname = $this->request->getData('firstName');
        $myemail = $this->request->getData('email');
        $mypass = Security::hash($this->request->getData('password'),'sha256', false);
        $mytoken = Security::hash(Security::randomBytes(32));

        $user->name = $myname;
        $user->email = $myemail;
        $user->password - $hasher->hash($mypass);
        $user->token = $mytoken;
        $user->created_at = date('Y-m-d H:i:s');
        $user->update_at = date('Y-m-d H:i:s');
        if($userTable->save($user)){
            $this->flash->set("Register successful, your connfirmation email has been sent", ['elemennt'=>success]);

            TransportFactory::setConfig('mailtrap', [
              'host' => 'smtp.mailtrap.io',
              'port' => 2525,
              'username' => '4c4a87ef71fb4a',
              'password' => 'a7c681d69ddac7',
              'className' => 'Smtp'
            ]);

            $email = new Email('default');
            $email->transport('mailtrap');
            $email->emailFormat('html');
            $email->from('mezigan@gmail.com','Alastair Micallef');
            $email->subject('Please confirm your email to activation your accout');
            $email->to($myemail);
            $email->send('hai '.$myname.'<br/>Please confirm your email link below<br/><a href="http://localhost:/users/verification/'.$mytoken.'">Verification Email</a>Thanks you for joining us');
        }else{
            $this->flash->set("Register failed,please try agai", ['elemennt'=>error]);            }
    }

}

我试过在线搜索但不幸的是我找不到任何东西提前谢谢

\Cake\ORM\Table::newEntity() 在 4.x 中没有输入就不再工作。如果你想创建空实体,你现在必须使用 \Cake\ORM\Table::newEmptyEntity() 方法,这是明确用于此目的的方法。

另见