Подтвердить что ты не робот

Ошибка: Class 'App\Model\Entity\DefaultPasswordHasher' не найден

<?php
namespace App\Model\Entity;

use Cake\ORM\Entity;

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

    /**
     * Fields that can be mass assigned using newEntity() or patchEntity().
     * Note that '*' is set to true, which allows all unspecified fields to be
     * mass assigned. For security purposes, it is advised to set '*' to false
     * (or remove), and explicitly make individual fields accessible as needed.
     *
     * @var array
     */
    protected $_accessible = [
        '*' => true,
        'id' => false,
    ];

    protected function _setPassword($value)
    {
        $hasher = new DefaultPasswordHasher();
        return $hasher->hash($value);
    }
}

Вот мой код в user.php. Я использую пароль и получил эту ошибку

Ошибка: класс 'App\Model\Entity\DefaultPasswordHasher' не найден. Файл C:\xamp\htdocs\bookmarker\src\Model\Entity\User.php Линия: 27

4b9b3361

Ответ 1

Мне не хватало следующей строки:

use Cake\Auth\DefaultPasswordHasher;

Вот почему я получил ошибку.