首页 > 解决方案 > 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 :

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 :-)

标签: symfonysymfony4

解决方案


如果没有过度设计解决方案,我不相信这是可能的。我认为最简单的解决方案是在资源目录和公共 Symfony 文件夹之间创建符号链接。

这样做时要小心,因为你可能会暴露你可能不想暴露的东西。

您可以像这样创建符号链接:

ln -s /opt/foo /usr/bin/bar

你可以在这里看到更好的解释。


推荐阅读