gpt4 book ai didi

php - Laravel 5.2 - 方法 auth 不存在

转载 作者:行者123 更新时间:2023-12-05 06:34:44 25 4
gpt4 key购买 nike

我最近克隆了一个 Laravel 5.2 项目。运行 composer install 后,每次执行 Artisan 命令后以及尝试访问应用程序时,我都会收到以下错误:

Method auth does not exist

我可以在网上找到类似的“方法不存在”问题,但与“auth”无关。我相信所指的“auth”类是内置的,可以用作各种路由的中间件。但是,我不知道如何解决这个问题。

我试过:

  • composer dump-autoload -o
  • 删除供应商库并使用 composer 重新安装
  • 重置到远程分支
  • 重新克隆存储库
  • 在 PHP 5.6 和 7.1 下运行

如有任何帮助,我们将不胜感激!

我的 Composer 文件:

{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.2.*",
"gloudemans/calendar": "dev-master",
"zizaco/entrust": "5.2.x-dev",
"laravelcollective/html": "5.2.*",
"guzzlehttp/guzzle": "~6.0",
"predis/predis": "~1.0",
"aws/aws-sdk-php": "~3.0",
"mpociot/laravel-apidoc-generator": "^2.0"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1",
"symfony/dom-crawler": "~3.0",
"symfony/css-selector": "~3.0"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {

"pre-update-cmd": [
"php artisan clear-compiled"
],
"post-update-cmd": [
"php artisan optimize"
],
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
}
}

来自 laravel.log 文件的错误堆栈跟踪:

[2018-05-01 12:49:56] local.ERROR: BadMethodCallException: Method auth does not exist. in /Applications/XAMPP/xamppfiles/htdocs/[ProjectName]/vendor/laravel/framework/src/Illuminate/Support/Traits/Macroable.php:81 Stack trace:

  1. /Applications/XAMPP/xamppfiles/htdocs/[ProjectName]/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(213): Illuminate\Routing\Router->__call('auth', Array)
  2. /Applications/XAMPP/xamppfiles/htdocs/[ProjectName]/app/Http/routes.php(424): Illuminate\Support\Facades\Facade::__callStatic('auth', Array)
  3. /Applications/XAMPP/xamppfiles/htdocs/[ProjectName]/app/Providers/RouteServiceProvider.php(41): require('/Applications/X...')
  4. [internal function]: App\Providers\RouteServiceProvider->App\Providers{closure}(Object(Illuminate\Routing\Router))
  5. /Applications/XAMPP/xamppfiles/htdocs/[ProjectName]/vendor/laravel/framework/src/Illuminate/Routing/Router.php(354): call_user_func(Object(Closure), Object(Illuminate\Routing\Router))
  6. /Applications/XAMPP/xamppfiles/htdocs/[ProjectName]/app/Providers/RouteServiceProvider.php(42): Illuminate\Routing\Router->group(Array, Object(Closure))
  7. [internal function]: App\Providers\RouteServiceProvider->map(Object(Illuminate\Routing\Router))
  8. /Applications/XAMPP/xamppfiles/htdocs/[ProjectName]/vendor/laravel/framework/src/Illuminate/Container/Container.php(507): call_user_func_array(Array, Array)
  9. /Applications/XAMPP/xamppfiles/htdocs/[ProjectName]/vendor/laravel/framework/src/Illuminate/Foundation/Support/Providers/RouteServiceProvider.php(72): Illuminate\Container\Container->call(Array)
  10. /Applications/XAMPP/xamppfiles/htdocs/[ProjectName]/vendor/laravel/framework/src/Illuminate/Foundation/Support/Providers/RouteServiceProvider.php(31): Illuminate\Foundation\Support\Providers\RouteServiceProvider->loadRoutes()
  11. /Applications/XAMPP/xamppfiles/htdocs/[ProjectName]/app/Providers/RouteServiceProvider.php(29): Illuminate\Foundation\Support\Providers\RouteServiceProvider->boot(Object(Illuminate\Routing\Router))
  12. [internal function]: App\Providers\RouteServiceProvider->boot(Object(Illuminate\Routing\Router))
  13. /Applications/XAMPP/xamppfiles/htdocs/[ProjectName]/vendor/laravel/framework/src/Illuminate/Container/Container.php(507): call_user_func_array(Array, Array)
  14. /Applications/XAMPP/xamppfiles/htdocs/[ProjectName]/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(734): Illuminate\Container\Container->call(Array)
  15. /Applications/XAMPP/xamppfiles/htdocs/[ProjectName]/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(717): Illuminate\Foundation\Application->bootProvider(Object(App\Providers\RouteServiceProvider)) 15 [internal function]: Illuminate\Foundation\Application->Illuminate\Foundation{closure}(Object(App\Providers\RouteServiceProvider), 16)
  16. /Applications/XAMPP/xamppfiles/htdocs/[ProjectName]/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(718): array_walk(Array, Object(Closure))
  17. /Applications/XAMPP/xamppfiles/htdocs/[ProjectName]/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/BootProviders.php(17): Illuminate\Foundation\Application->boot()
  18. /Applications/XAMPP/xamppfiles/htdocs/[ProjectName]/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(203): Illuminate\Foundation\Bootstrap\BootProviders->bootstrap(Object(Illuminate\Foundation\Application))
  19. /Applications/XAMPP/xamppfiles/htdocs/[ProjectName]/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(208): Illuminate\Foundation\Application->bootstrapWith(Array)
  20. /Applications/XAMPP/xamppfiles/htdocs/[ProjectName]/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(105): Illuminate\Foundation\Console\Kernel->bootstrap()
  21. /Applications/XAMPP/xamppfiles/htdocs/[ProjectName]/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
  22. {main}

最佳答案

将 Route::auth() 替换为以下路由,或者

// Authentication Routes...
$this->get('login', 'Auth\LoginController@showLoginForm')->name('login');
$this->post('login', 'Auth\LoginController@login');
$this->post('logout', 'Auth\LoginController@logout')->name('logout');

// Registration Routes...
$this->get('register', 'Auth\RegisterController@showRegistrationForm')->name('register');
$this->post('register', 'Auth\RegisterController@register');

// Password Reset Routes...
$this->get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm');
$this->post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail');
$this->get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm');
$this->post('password/reset', 'Auth\ResetPasswordController@reset');

关于php - Laravel 5.2 - 方法 auth 不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50132106/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com