简体   繁体   English

将会话连接到Laravel 5.2中的config / app.php设置

[英]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.

相关问题 laravel 5.2 在 app.php 中设置默认语言环境不起作用 - laravel 5.2 setting default locale in app.php does not work laravel如何阅读app / config / app.php调试变量 - laravel how to read app/config/app.php debug variable Laravel 5中config / app.php提供者数组中:: class的含义是什么 - What is the meaning of ::class in config/app.php provider array in Laravel 5 Laravel config/app.php 和.env 文件中的应用程序环境变量 - Laravel Application Environment variable in config/app.php and .env file Laravel 5,即使更新app.php和config.php后也找不到CLass HTML - Laravel 5 , CLass HTML not find even after updating app.php and config.php 理解laravel app.php 中的数组 - Understanding arrays in laravel app.php 如何从 Laravel 的 config/app.php 中获取客户端 ip 地址? - How to get the client ip address from Laravel's config/app.php? 我们如何从数据库或laravel 5 config文件夹中app.php的其他文件中访问数据 - how do we access data from database or other files in app.php of the config folder in laravel 5 如何修复config / app.php Laravel中的提供程序,它始终未找到错误 - How to fix provider in config/app.php Laravel that's starting not found error Laravel 如何从 config\app.php => 提供者中自动加载所有提供者类 - How Laravel auto load all provider classes from config\app.php => providers
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM