在 Laravel 5.2 中将 session 连接到 config/app.php 设置
Concatenate session to config/app.php setting in Laravel 5.2
希望这是一个容易回答的问题,所以正如我在 header 中提到的,我将如何在我的 config/app.php 文件中执行类似于以下内容的操作:
'partial_year_img_src' => '/img/' . session('year'),
这不是推荐的做法,但您可以直接访问全局 PHP 变量:
'partial_year_img_src' => '/img/' . $_SESSION['year'],
Update: *As ceejayoz has commented, we can not access a value set in the Session object through the PHP Super Global because Laravel has its own implementation. So this solution is only valid if you have set the superGlobal with that value previously. *
也许您可以创建一个包含将 return 该路径的函数的 Helper。类似于:
ImageHelper::getImagePath();
您可以在那里访问 Laravel 会话。
希望这是一个容易回答的问题,所以正如我在 header 中提到的,我将如何在我的 config/app.php 文件中执行类似于以下内容的操作:
'partial_year_img_src' => '/img/' . session('year'),
这不是推荐的做法,但您可以直接访问全局 PHP 变量:
'partial_year_img_src' => '/img/' . $_SESSION['year'],
Update: *As ceejayoz has commented, we can not access a value set in the Session object through the PHP Super Global because Laravel has its own implementation. So this solution is only valid if you have set the superGlobal with that value previously. *
也许您可以创建一个包含将 return 该路径的函数的 Helper。类似于:
ImageHelper::getImagePath();
您可以在那里访问 Laravel 会话。