Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR) Call to undefined function App\needsRehash()

问题描述

我正在做一个旧的 Laravel 项目, 当我启动项目时一切顺利,但是当我尝试添加用户(姓名、名字、密码 ..)时出现错误。 我正在使用 wamp。我也使用了 xampp,但仍然是同样的问题,我找不到任何解决方案,请帮助我。 这是 composer.json

    {
  "name": "laravel/laravel","description": "The Laravel Framework.","keywords": [
    "framework","laravel"
  ],"license": "MIT","type": "project","require": {
    "PHP": ">=7.0.0","barryvdh/laravel-cors": "^0.11.3","doctrine/dbal": "^2.5","fideloper/proxy": "~3.3","intervention/image": "^2.4","ircmaxell/password-compat": "^1.0","kylekatarnls/laravel-carbon-2": "^1.0.0","laravel/framework": "5.5.*","laravel/passport": "4.0.*","laravel/tinker": "~1.0","laravelcollective/html": "^5.5","nesbot/carbon": "2.22.0 as 1.34.0","paragonie/random_compat": "2.*","spatie/laravel-medialibrary": "^6.0"
  },"require-dev": {
    "filp/whoops": "~2.0","fzaninotto/faker": "~1.4","mockery/mockery": "0.9.*","PHPunit/PHPunit": "~5.7","laravel/dusk": "^2.0"
  },"autoload": {
    "classmap": [
      "database"
    ],"psr-4": {
      "App\\": "app/"
    }
  },"autoload-dev": {
    "psr-4": {
      "Tests\\": "tests/"
    }
  },"extra": {
    "laravel": {
      "dont-discover": [
      ]
    }
  },"scripts": {
    "post-root-package-install": [
      "PHP -r \"file_exists('.env') || copy('.env.example','.env');\""
    ],"post-create-project-cmd": [
      "PHP artisan key:generate"
    ],"post-install-cmd": [
      "Illuminate\\Foundation\\ComposerScripts::postInstall"
    ],"post-update-cmd": [
      "Illuminate\\Foundation\\ComposerScripts::postUpdate"
    ]
  },"config": {
    "preferred-install": "dist","sort-packages": true,"optimize-autoloader": true
  }
}

这是项目的错误线

     public function setPasswordAttribute($input)
    {                                                       
        if ($input)
            //Probleme de hashage
           $this->attributes['password'] = needsRehash($input) ? Hash::make($input) : $input;
        
    }

解决方法

尝试将 needsRehash 更改为 Hash::needsRehash

老实说,我很惊讶 Laravel 应用程序能够运行,因为据我所知,框架中从来没有 needsRehash 不是静态方法。

有关详细信息,请参阅 Laravel Docs