Laravel - 如何恢复本地存储符号链接和刷新

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/48510683/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 17:18:43  来源:igfitidea点击:

Laravel - How to revert local storage symlink and refresh

laravelstoragesymlink

提问by rushtoni88

When I save images to storage they show in the storage/appdirectory, but they don't show in public/storage. I also noticed that a storage/app/publicdirectory seems to have been created which also contains everything within storage/app.

当我将图像保存到存储时,它们会显示在storage/app目录中,但不会显示在public/storage 中。我还注意到似乎已经创建了一个storage/app/public目录,其中还包含 storage/app 中的所有内容。

I can't work out how I managed to cause this mess, and I think it might make sense to revert these directories to how it should have been to begin with (with a new laravel project), remove any existing symlinks, and start again - does this sound like the best approach? And how would I go about doing this if I have set the symlink up incorrectly?

我无法弄清楚我是如何造成这种混乱的,我认为将这些目录恢复到它应该是如何开始的(使用新的 Laravel 项目),删除任何现有的符号链接,然后重新开始可能是有意义的- 这听起来像是最好的方法吗?如果我错误地设置了符号链接,我该怎么做?

回答by Alexey Mezenin

You can always delete the link:

您可以随时删除链接:

cd public
rm storage

And create a new one without using the storage:linkcommand if you need to link different locations:

storage:link如果需要链接不同的位置,请在不使用命令的情况下创建一个新的:

\File::link(storage_path('dir1'), public_path('dir2'));

Or create a symlink manually:

或者手动创建一个符号链接

ln -s /full/path/to/storage/dir1 /full/path/to/public/dir2

回答by rushtoni88

That is actually how it should be! Laravel has a command to symlink your public directory to the storage directory:

其实应该是这样的!Laravel 有一个命令可以将你的公共目录符号链接到存储目录:

php artisan storage:link

The idea is to keep a persistent storage between deployments.

这个想法是在部署之间保持持久存储。

This convention will keep your publicly accessible files in one directory that can be easily shared across deployments when using zero down-time deployment systems like Envoyer.

该约定将您的可公开访问的文件保存在一个目录中,当使用 Envoyer 等零停机时间部署系统时,该目录可以轻松地在部署之间共享。

https://laravel.com/docs/5.5/filesystem

https://laravel.com/docs/5.5/filesystem