【问题标题】:Why my route is not working perfectly in Laravel 8?为什么我的路线在 Laravel 8 中不能完美运行?
【发布时间】:2021-01-18 19:46:12
【问题描述】:

我正在使用 Laravel 8 和 fortify auth 而没有 Jetstream。

web.php

Route::get('/facade_version', function () {
    dd('EXAMPLE');
})->name('postcard.facade');

以上是我的路线

index.blade.php

<a href="{{ route('postcard.facade') }}" type="a" class="btn btn-success">facade postcard</a>

屏幕输出

Route [postcard.facade] not defined. (View: E:\github\LARAVEL\laravel8-fortify\resources\views\facade\index.blade.php)

我尝试在 url 中使用 http://127.0.0.1:8000/facade_version 的第二种方式

屏幕输出

404 | Not Found

一切正常,但我不知道是什么问题。

我以前也做过这种路线。

但这不起作用

看看下面的路线。效果很好。

Route::get('/post-cards', function () {
    $postcardService = new PostcardSendingService('USA', 4, 6);
    $postcardService->hello('Hello from Coder Tape USA!!', 'imrul.cse273@gmail.com');
})->name('postcard.index');

  • 我只是将链接编辑到/post-cardsss 而不是/post-cards' 然后再次找不到路线

注意

今天我在我的项目中运行了这些命令

php artisan config:clear
php artisan view:clear
php artisan cache:clear
php artisan route:cache
composer dump-autoload

【问题讨论】:

  • 您好,您的刀片视图文件路径是否类似于/resources/views/postcard/facade.blade.php?我假设您使用的是默认的 Laravel 视图路径配置,而不是在路由组内使用路由前缀或其他东西。路由名称中的点符号表示文件路径。如果可以,请发布您的 views 文件夹配置的树视图。祝你好运!

标签: php laravel facade


【解决方案1】:

用这个命令解决了

php artisan route:clear

然后再次运行项目

【讨论】:

    【解决方案2】:

    我已经尝试了 laravel 文档中的这些步骤并解决了我的问题

    composer install --optimize-autoloader --no-dev
    

    然后

    php artisan config:cache
    

    一次又一次

    php artisan route:cache
    

    这是最重要的可能,因为我们缺少路线信息

    php artisan view:cache
    

    伟大的 laravel documentation 在这里

    谢谢。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-12
      • 2022-01-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-26
      • 2021-08-25
      • 1970-01-01
      相关资源
      最近更新 更多