可捕获的致命错误:无法将类__PHP_Incomplete_Class的对象转换为字符串

尼尔斯

我想打开一个简单页面时出现错误。这是完整的错误:

ContextErrorException:可捕获的致命错误:无法将类__PHP_Incomplete_Class的对象转换为/Applications/mampstack-5.4.20-0/apache2/htdocs/engelsvandenbroecke/vendor/symfony/symfony/src/Symfony/Component/Security/Core/ Authentication / Token / AbstractToken.php 70行

我在symfony项目中所做的是:

  • 从数据库生成实体
  • 编辑用户实体以提高安全性
  • 编辑security.yml
  • 添加了两个数据夹具

这是我的用户实体类:

<?php

namespace Beachteam\BeachteamBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\AdvancedUserInterface;

/**
 * User
 *
 * @ORM\Table(name="user", uniqueConstraints={@ORM\UniqueConstraint(name="username_UNIQUE", columns={"username"})}, indexes={@ORM\Index(name="fk_users_roles_idx", columns={"role_id"})})
 * @ORM\Entity
 */
class User implements AdvancedUserInterface
{
    /**
     * @var string
     *
     * @ORM\Column(name="username", type="string", length=45, nullable=false)
     */
    private $username;

    /**
     * @var string
     *
     * @ORM\Column(name="password", type="string", length=60, nullable=false)
     */
    private $password;

    /**
     * @var string
     *
     * @ORM\Column(name="salt", type="string", length=30, nullable=false)
     */
    private $salt;

    /**
     * @var string
     *
     * @ORM\Column(name="firstname", type="string", length=45, nullable=false)
     */
    private $firstname;

    /**
     * @var string
     *
     * @ORM\Column(name="surname", type="string", length=45, nullable=false)
     */
    private $surname;

    /**
     * @var string
     *
     * @ORM\Column(name="email", type="string", length=255, nullable=false)
     */
    private $email;

    /**
     * @var string
     *
     * @ORM\Column(name="token", type="string", length=45, nullable=true)
     */
    private $token;

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="created", type="datetime", nullable=false)
     */
    private $created;

    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;

    /**
     * @var \Beachteam\BeachteamBundle\Entity\Role
     *
     * @ORM\ManyToOne(targetEntity="Beachteam\BeachteamBundle\Entity\Role")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="role_id", referencedColumnName="id")
     * })
     */
    private $role;

    private $plainPassword;

    /**
     * Constructor
     */
    public function __construct()
    {
        $this->salt = base_convert(sha1(uniqid(mt_rand(), true)), 16, 36);
    }


    /**
     * Set username
     *
     * @param string $username
     * @return User
     */
    public function setUsername($username)
    {
        $this->username = $username;

        return $this;
    }

    /**
     * Get username
     *
     * @return string 
     */
    public function getUsername()
    {
        return $this->username;
    }

    /**
     * Set password
     *
     * @param string $password
     * @return User
     */
    public function setPassword($password)
    {
        $this->password = $password;

        return $this;
    }

    /**
     * Get password
     *
     * @return string 
     */
    public function getPassword()
    {
        return $this->password;
    }

    /**
     * Set salt
     *
     * @param string $salt
     * @return User
     */
    public function setSalt($salt)
    {
        $this->salt = $salt;

        return $this;
    }

    /**
     * Get salt
     *
     * @return string 
     */
    public function getSalt()
    {
        return $this->salt;
    }

    /**
     * Set firstname
     *
     * @param string $firstname
     * @return User
     */
    public function setFirstname($firstname)
    {
        $this->firstname = $firstname;

        return $this;
    }

    /**
     * Get firstname
     *
     * @return string 
     */
    public function getFirstname()
    {
        return $this->firstname;
    }

    /**
     * Set surname
     *
     * @param string $surname
     * @return User
     */
    public function setSurname($surname)
    {
        $this->surname = $surname;

        return $this;
    }

    /**
     * Get surname
     *
     * @return string 
     */
    public function getSurname()
    {
        return $this->surname;
    }

    /**
     * Set email
     *
     * @param string $email
     * @return User
     */
    public function setEmail($email)
    {
        $this->email = $email;

        return $this;
    }

    /**
     * Get email
     *
     * @return string 
     */
    public function getEmail()
    {
        return $this->email;
    }

    /**
     * Set token
     *
     * @param string $token
     * @return User
     */
    public function setToken($token)
    {
        $this->token = $token;

        return $this;
    }

    /**
     * Get token
     *
     * @return string 
     */
    public function getToken()
    {
        return $this->token;
    }

    /**
     * Set created
     *
     * @param \DateTime $created
     * @return User
     */
    public function setCreated($created)
    {
        $this->created = $created;

        return $this;
    }

    /**
     * Get created
     *
     * @return \DateTime 
     */
    public function getCreated()
    {
        return $this->created;
    }

    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set role
     *
     * @param \Beachteam\BeachteamBundle\Entity\Role $role
     * @return User
     */
    public function setRoles(\Beachteam\BeachteamBundle\Entity\Role $role = null)
    {
        $this->role = $role;

        return $this;
    }

    /**
     * Get role
     *
     * @return \Beachteam\BeachteamBundle\Entity\Role 
     */
    public function getRoles()
    {
        return array($this->role->getName());
    }

    public function eraseCredentials()
    {
        $this->setPlainPassword(null);
    }

    public function getPlainPassword()
    {
        return $this->plainPassword;
    }

    public function setPlainPassword($plainPassword)
    {
        $this->plainPassword = $plainPassword;
    }

    /**
     * Implementation of AdvancedUserInterface method
     *
     * @return boolean
     */
    public function isAccountNonExpired()
    {
        return true;
    }

    /**
     * Implementation of AdvancedUserInterface method
     *
     * @return boolean
     */
    public function isAccountNonLocked()
    {
        return true;
    }

    /**
     * Implementation of AdvancedUserInterface method
     *
     * @return boolean
     */
    public function isCredentialsNonExpired()
    {
        return true;
    }

    /**
     * Implementation of AdvancedUserInterface method
     *
     * @return boolean
     */
    public function isEnabled()
    {
        return true;
    }
}

我的security.yml:

    security:
encoders:
    Beachteam\BeachteamBundle\Entity\User:
        algorithm: bcrypt
        cost: 15

role_hierarchy:
    ROLE_SUPER_ADMIN: ROLE_ADMIN

providers:
    users:
        entity:
            class: BeachteamBundle:User
            property: username

firewalls:
    dev:
        pattern:  ^/(_(profiler|wdt)|css|images|js)/
        security: false

    secured_area:
        pattern: ^/
        anonymous: ~
        form_login:
            login_path: beach_team_loginpage
            check_path: beach_team_logincheck
            username_parameter: login[username]
            password_parameter: login[password]
            always_use_default_target_path: true
            default_target_path: beach_team_adminpage
        logout:
            path:   beach_team_logout
            target: beach_team_loginpage
        remember_me:
             key:      "%secret%"
             lifetime: 31536000 # 365 days in seconds
             path:     /
             domain:   ~ # Defaults to the current domain from $_SERVER
             remember_me_parameter: remember

access_control:
    #- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
马克西姆·汗·马戈梅多夫(Maxim Khan-Magomedov)

此错误通常意味着您尝试反序列化对象而没有为该对象加载类。因此,您应该以某种方式定义此类(例如,包含文件),然后反序列化。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

PHP,可捕获的致命错误:无法将mysqli类的对象转换为字符串

来自分类Dev

可捕获的致命错误:无法将类dayDaytimeFields的对象转换为字符串

来自分类Dev

可捕获的致命错误:无法将MongoCursor类的对象转换为字符串

来自分类Dev

Symfony 2可捕获的致命错误:无法将类UserCategory的对象转换为字符串

来自分类Dev

可捕获的致命错误:无法将 AppBundle\Entity\Location 类的对象转换为字符串

来自分类Dev

可捕获的致命错误:“”行的“”中的类“”的对象无法转换为字符串

来自分类Dev

可捕获的致命错误:类的对象...无法转换为字符串

来自分类Dev

symfony2可捕获的致命错误:类的对象无法转换为字符串

来自分类Dev

可捕获的致命错误:Instamojo类的对象无法转换为字符串

来自分类Dev

可捕获的致命错误:无法在行114中将类PDOStatement的对象转换为字符串

来自分类Dev

可捕获的致命错误:注册时无法将类mysqli_result的对象转换为字符串

来自分类Dev

可捕获的致命错误:无法将类Proxies \ __ CG __ \ AppBundle \ Entity \ Ticket的对象转换为字符串

来自分类Dev

可捕获的致命错误:注册时无法将类mysqli_result的对象转换为字符串

来自分类Dev

Symfony - 可捕获的致命错误:无法将类 App\Entity\Question 的对象转换为字符串

来自分类Dev

可捕获的致命错误:无法在php中将类mysqli_result的对象转换为字符串

来自分类Dev

可捕获的致命错误:无法转换为字符串?

来自分类Dev

可捕获的致命错误:无法转换为字符串?

来自分类Dev

可捕获的致命错误:WP_User类的对象无法在第139行的/ directory /中转换为字符串

来自分类Dev

Symfony 2.8可捕获的致命错误:类...的对象无法转换为字符串(一对多和多对一)

来自分类Dev

可捕获的致命错误:在第30行的C:\ xampp \ htdocs \ testing.php中,类DateInterval的对象无法转换为字符串

来自分类Dev

可捕获的致命错误:无法将对象转换为字符串

来自分类Dev

可恢复的致命错误:类 PDOStatement 的对象无法转换为字符串 PHP 错误消息

来自分类Dev

可恢复的致命错误:无法将类SendGrid \ Mail \ Mail的对象转换为字符串

来自分类Dev

可恢复的致命错误:无法将 PDOStatement 类的对象转换为字符串

来自分类Dev

可捕获的致命错误:类别WP_User的对象无法在第139行的/ directory /中转换为字符串

来自分类Dev

未捕获的错误:无法将类Core的对象转换为字符串

来自分类Dev

可捕获的致命错误:EntityManager无法转换为字符串

来自分类Dev

可捕获的致命错误:无法将PDO类的对象转换为

来自分类Dev

S3Client PHP SDK:无法将类<class>的对象转换为字符串

Related 相关文章

  1. 1

    PHP,可捕获的致命错误:无法将mysqli类的对象转换为字符串

  2. 2

    可捕获的致命错误:无法将类dayDaytimeFields的对象转换为字符串

  3. 3

    可捕获的致命错误:无法将MongoCursor类的对象转换为字符串

  4. 4

    Symfony 2可捕获的致命错误:无法将类UserCategory的对象转换为字符串

  5. 5

    可捕获的致命错误:无法将 AppBundle\Entity\Location 类的对象转换为字符串

  6. 6

    可捕获的致命错误:“”行的“”中的类“”的对象无法转换为字符串

  7. 7

    可捕获的致命错误:类的对象...无法转换为字符串

  8. 8

    symfony2可捕获的致命错误:类的对象无法转换为字符串

  9. 9

    可捕获的致命错误:Instamojo类的对象无法转换为字符串

  10. 10

    可捕获的致命错误:无法在行114中将类PDOStatement的对象转换为字符串

  11. 11

    可捕获的致命错误:注册时无法将类mysqli_result的对象转换为字符串

  12. 12

    可捕获的致命错误:无法将类Proxies \ __ CG __ \ AppBundle \ Entity \ Ticket的对象转换为字符串

  13. 13

    可捕获的致命错误:注册时无法将类mysqli_result的对象转换为字符串

  14. 14

    Symfony - 可捕获的致命错误:无法将类 App\Entity\Question 的对象转换为字符串

  15. 15

    可捕获的致命错误:无法在php中将类mysqli_result的对象转换为字符串

  16. 16

    可捕获的致命错误:无法转换为字符串?

  17. 17

    可捕获的致命错误:无法转换为字符串?

  18. 18

    可捕获的致命错误:WP_User类的对象无法在第139行的/ directory /中转换为字符串

  19. 19

    Symfony 2.8可捕获的致命错误:类...的对象无法转换为字符串(一对多和多对一)

  20. 20

    可捕获的致命错误:在第30行的C:\ xampp \ htdocs \ testing.php中,类DateInterval的对象无法转换为字符串

  21. 21

    可捕获的致命错误:无法将对象转换为字符串

  22. 22

    可恢复的致命错误:类 PDOStatement 的对象无法转换为字符串 PHP 错误消息

  23. 23

    可恢复的致命错误:无法将类SendGrid \ Mail \ Mail的对象转换为字符串

  24. 24

    可恢复的致命错误:无法将 PDOStatement 类的对象转换为字符串

  25. 25

    可捕获的致命错误:类别WP_User的对象无法在第139行的/ directory /中转换为字符串

  26. 26

    未捕获的错误:无法将类Core的对象转换为字符串

  27. 27

    可捕获的致命错误:EntityManager无法转换为字符串

  28. 28

    可捕获的致命错误:无法将PDO类的对象转换为

  29. 29

    S3Client PHP SDK:无法将类<class>的对象转换为字符串

热门标签

归档