Laragon,laravel符号链接不工作
我将laravel与laragon一起使用,一切正常,除了上传图像时返回Laragon,laravel符号链接不工作,laravel,laravel-5,laravel-5.4,laravel-5.6,laragon,Laravel,Laravel 5,Laravel 5.4,Laravel 5.6,Laragon,我将laravel与laragon一起使用,一切正常,除了上传图像时返回404,public/storage为空,但是storage/app/public有文件,也public/public有文件,因此它在公用文件夹中创建了一个错误的公用文件夹,我确实运行了php artisan storage:link命令,正如我所说,它创建了存储链接,我可以在编辑器中看到它,但是文件转到public/public而不是public/storage,我如何才能让它工作?我想这是laragon的问题,因为它在其
404
,public/storage
为空,但是storage/app/public
有文件,也public/public
有文件,因此它在公用文件夹中创建了一个错误的公用文件夹,我确实运行了php artisan storage:link命令
,正如我所说,它创建了存储链接,我可以在编辑器中看到它,但是文件转到public/public
而不是public/storage
,我如何才能让它工作?我想这是laragon的问题,因为它在其他环境中也能工作,我也用一个“命名”url运行我的网站:myproject.test,我使用apache2作为web服务器,请帮助修复它如果你在linux上,你可以使用
ln -s [source] [virtual]
mklink /j [virtual] [source]
创建虚拟链接。在windows上,您可以使用
ln -s [source] [virtual]
mklink /j [virtual] [source]
做同样的事
请注意,您可能需要使用完整路径来创建链接。我在拉拉贡使用了这种方法,它是有效的。如果符号链接指向所需文件夹,请在创建符号链接后双击该链接,检查其是否有效。如果没有,则说明配置有问题
奖金 我创建了一个控制台命令来实现自动化,也许您可以使用它: 用法:
php artisan安装:symlink
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class installSymlink extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'install:symlink';
/**
* The console command description.
*
* @var string
*/
protected $description = 'This artisan command installs pinpacker symlinks';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
//
$links = ["./public/thumbnails","./public/resized"];
$folders = ["./storage/app/public/thumbnails/","./storage/app/public/resized/"];
chdir(base_path());
try {
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
foreach($links as $i => $link){
$command = 'mklink /j "' . str_replace('/', '\\', $link) . '" "' . str_replace('/', '\\', $folders[$i]) . '"';
echo $command."\n";
exec($command);
}
} else {
foreach($links as $i => $link){
$command = 'ln -s ' . realpath($folders[$i]) . ' ' . $link;
echo $command ."\n";
exec($command);
}
}
printf("Symlinks created.\n");
} catch (Exception $e) {
printf($e->getMessage());
print_r($e);
}
}
}
您好,谢谢,但它不起作用,我在windows 10上,我的laragon在C:/laragon我运行mklink/j[virtual][source]命令,它创建了文件夹,但文件没有同步,因此在发生更改时不会更新虚拟文件夹:(,在我的xammp中,一切正常。)