为什么不使用config我的标题标签的变化()?

问题描述 投票:1回答:2

我下面那里他继续更改使用<title></title>index.blade.phpconfig()标签的教程。我做他做同样的事情,但对于一些奇怪的原因,它不是为我工作。

我在做什么错了,我该如何解决?

这里的index.blade.php

<!doctype html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>{{config('app.name', 'LSAPP')}}</title>
</head>
<body>

</body>
</html>

这里的PagesController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class PagesController extends Controller
{
    public function index() {
        return view('pages.index');
    }
}

这里的web.php

Route::get('/', 'PagesController@index');

这是我的.env文件的一部分:

APP_NAME=LSAPP
php laravel debugging
2个回答
0
投票
<title>{{config('app.name')}}</title>

尝试这个。这是什么打印?如果打印从config/app.php默认值(这是Laravel默认情况下),这意味着你的.env是错误的以某种方式。

默认情况下,在config/app.php所有配置值包含env()方法。其中第一个参数是这是在你的.env文件中定义的键,第二个是默认值。

下面是配置助手文档:

https://laravel.com/docs/5.7/helpers#method-config

你也可以尝试到您的.ENV APP_NAME值括到双引号:

APP_NAME="SOME VALUE"

0
投票

尝试运行php artisan config:cache它会清除旧.ENV文件和cachced新的。

© www.soinside.com 2019 - 2024. All rights reserved.