[英]How can I change location of symlink folder while doing PHP artisan storage: link?
Got some issues on production.在生产中遇到了一些问题。 In details, I have deployed Laravel project on shared hosting cPanel, I have kept my project in root folder and Laravel`s public folder kept inside public_html, and when I run PHP artisan storage: link it creates a symlink of storage folder in myfolder/public but I want it to go inside public_html具体来说,我已经在共享主机 cPanel 上部署了 Laravel 项目,我将我的项目保存在根文件夹中,并将 Laravel 的公共文件夹保存在 public_html 中,当我运行 PHP artisan storage: link 时,它会在 myfolder/ 中创建一个存储文件夹的符号链接public,但我希望它进入 public_html
How can I do that?我怎样才能做到这一点?
You can create custom symlink via cli !您可以通过 cli 创建自定义符号链接!
cd to your laravel project directory and run the following command cd 到你的 Laravel 项目目录并运行以下命令
ln -sr storage ../public_html/storage
This will create a symbolic link of your storage folder inside your public_html folder.这将在 public_html 文件夹中创建存储文件夹的符号链接。
A solution could be to make a custom artisan command, something like storage_custom:link
and copy the contents of the original storage:link
comamnd and just change the paths as you want them to be.一个解决方案可能是创建一个自定义的工匠命令,比如storage_custom:link
并复制原始storage:link
comamnd 的内容,然后根据需要更改路径。 Here you can see the original storage:link
command in Laravel.在这里你可以看到 Laravel 中原始的storage:link
命令。
class StorageLinkCommand extends Command
{
/**
* The console command signature.
*
* @var string
*/
protected $signature = 'storage:link';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Create a symbolic link from "public/storage" to "storage/app/public"';
/**
* Execute the console command.
*
* @return void
*/
public function handle()
{
if (file_exists(public_path('storage'))) {
return $this->error('The "public/storage" directory already exists.');
}
$this->laravel->make('files')->link(
storage_path('app/public'), public_path('storage')
);
$this->info('The [public/storage] directory has been linked.');
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.