symfony - How to access outside folders when running?
问题描述
When my application is running (server: run), I want to access a folder outside my project directory.
I use Symfony 4 and PHP7. I have this architecture :
/ressources
/symfony_project
/other_folder
And I would like to render an image from /ressources
like ../ressources/myimage.png
.
I am stucked with this url http://127.0.0.1/ressources/myimage.png
because 127.0.0.1
= /symfony_project
. So it is not working.
Do I have to use a symlink? How do I do that?
Thanks for your help :-)
解决方案
如果没有过度设计解决方案,我不相信这是可能的。我认为最简单的解决方案是在资源目录和公共 Symfony 文件夹之间创建符号链接。
这样做时要小心,因为你可能会暴露你可能不想暴露的东西。
您可以像这样创建符号链接:
ln -s /opt/foo /usr/bin/bar
你可以在这里看到更好的解释。
推荐阅读
- ios - 在敲击键盘键后触发keyboardDidShowNotification 和keyboardWillShowNotification
- reactjs - 在没有上下文的功能组件中向上传递状态
- c# - 具有隐式转换的重载解决方案
- r - R - 每日回报的 adfTest
- ios - SwiftUI 无法在 Bundle 中找到图像,但图像在正确的路径中?
- javascript - 如何选择在reactjs中选择的默认复选框
- kotlin - Dagger2 和 Kotlin:@Binds 不适用于 @IntoMap
- python - itertools.product 真的会生成所有可能的排列吗?
- json - 将 Spark 数据帧导出为带有自定义元数据的 JSON 数组
- java - java bean创建、休眠和spa的问题