【问题标题】:Laravel 5.4.21 default authentication links does not workLaravel 5.4.21 默认认证链接不起作用
【发布时间】:2023-03-25 06:16:01
【问题描述】:

我正在关注此用户手册:https://laravel.com/docs/5.4/authentication 为 Laravel 5.4 编写

我首先通过发出以下命令创建了一个新的 Laravel 应用程序:

$ laravel new mysite

在 .env 文件中我更改了 DB_DATABASE=mysite_db

然后我切换到/Code/mysite目录并发出:

$ php artisan make:auth
$ php artisan migrate

当我指向http://mysite.app/register 时,我收到消息:“抱歉,找不到您要查找的页面。” http://mysite.app/login 也一样。我也试过http://mysite.app/auth/register

为什么默认的身份验证路由不起作用?


routes/web.php 内容为:

Route::get('/', function () {
  return view('welcome');
});

Auth::routes();

Route::get('/home', 'HomeController@index')->name('home');

【问题讨论】:

  • 只有身份验证路由不起作用?你在 Apache2 上启用了 mod rewrite 吗?
  • 我有一个使用 laravel 5.3 的网站,它可以工作。我正在使用 Homestead,所以我想它应该默认启用。
  • 运行php artisan route:clear,创建自定义路由并尝试是否可行。 :)
  • @Troyer,我跑了php artisan route:clear 仍然无济于事。
  • 发出php artisan route:list --path=login时是否列出了路由?

标签: laravel laravel-5


【解决方案1】:

首先,运行 $php artisan make:auth

因为默认情况下,至少在 5.4 中,Laravel 不包含 Authentication 路由和视图。运行命令会生成它们。您会在Laravel Authentication Quickstart 中看到它。

【讨论】:

  • 哦,是的。没有足够早地看到cmets。现在更深入地研究它。
【解决方案2】:

好的,我自己解决了这个问题:

我第一次发布:

$ vagrant box list

要找出我下载的盒子,然后:

$ vagrant box remove laravel/homestead

然后我把我的宅基地从 1.0.1 升级到 2.1.0:

$ vagrant box add laravel/homestead

我还使用以下方法升级了我的宅基地流浪环境:

$ git clone https://github.com/laravel/homestead.git Homestead2
$ cd Homestead2
$ git checkout v5.2.4

在此之后,身份验证路由起作用了。

【讨论】:

    猜你喜欢
    • 2018-12-02
    • 2014-04-07
    • 2016-10-15
    • 2015-03-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多