[英]Concatenate session to config/app.php setting in Laravel 5.2
希望这是一个容易回答的问题,因此,正如我的标题中所述,我将如何在config / app.php文件中执行与以下操作类似的操作:
'partial_year_img_src' => '/img/' . session('year'),
It's not a recommended practice, but you could access the global PHP variable directly: 不建议这样做,但是您可以直接访问全局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. 更新:*正如ceejayoz所说,由于Laravel有自己的实现,因此我们无法通过PHP Super Global访问Session对象中设置的值。 So this solution is only valid if you have set the superGlobal with that value previously. 因此,仅当您先前将superGlobal设置为该值时,此解决方案才有效。 * *
Maybe you can create a Helper that contains a function that will return that path. 也许您可以创建一个包含将返回该路径的函数的Helper。 Something like: 就像是:
ImageHelper::getImagePath();
There you can access the Laravel Session. 在那里您可以访问Laravel会议。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.