webman phar打包 文件上传问题

hsk99

使用pahr打包后静态文件目录无法作为上传文件存储目录使用,有没有什么解决办法

使用:
截图
截图

错误日志

[2022-03-03 11:20:04] Could not move the file "/tmp/workerman.upload.jzop9B" to "phar:///mnt/c/Users/hushu/Desktop/XXXXXX/project/server/dev/ahxy/build/ahxy.phar/public/upload/product/20220303/622033e4eaa17.png" (rename(): Cannot rename a file across wrapper types) {"worker":null,"exception":"Webman\\Exception\\FileException: Could not move the file \"/tmp/workerman.upload.jzop9B\" to \"phar:///mnt/c/Users/hushu/Desktop/XXXXXX/project/server/dev/ahxy/build/ahxy.phar/public/upload/product/20220303/622033e4eaa17.png\" (rename(): Cannot rename a file across wrapper types) in phar:///mnt/c/Users/hushu/Desktop/XXXXXX/project/server/dev/ahxy/build/ahxy.phar/vendor/workerman/webman-framework/src/File.php:37
Stack trace:
#0 phar:///mnt/c/Users/hushu/Desktop/XXXXXX/project/server/dev/ahxy/build/ahxy.phar/app/api/controller/Product.php(323): Webman\\File->move()
#1 phar:///mnt/c/Users/hushu/Desktop/XXXXXX/project/server/dev/ahxy/build/ahxy.phar/vendor/workerman/webman-framework/src/App.php(233): app\\api\\controller\\Product->upload()
#2 phar:///mnt/c/Users/hushu/Desktop/XXXXXX/project/server/dev/ahxy/build/ahxy.phar/app/api/middleware/AccessControl.php(65): Webman\\App::Webman\\{closure}()
#3 phar:///mnt/c/Users/hushu/Desktop/XXXXXX/project/server/dev/ahxy/build/ahxy.phar/vendor/workerman/webman-framework/src/App.php(227): app\\api\\middleware\\AccessControl->process()
#4 phar:///mnt/c/Users/hushu/Desktop/XXXXXX/project/server/dev/ahxy/build/ahxy.phar/vendor/hsk99/webman-statistic/src/Statistic.php(22): Webman\\App::Webman\\{closure}()
#5 phar:///mnt/c/Users/hushu/Desktop/XXXXXX/project/server/dev/ahxy/build/ahxy.phar/vendor/workerman/webman-framework/src/App.php(227): Hsk99\\WebmanStatistic\\Statistic->process()
#6 phar:///mnt/c/Users/hushu/Desktop/XXXXXX/project/server/dev/ahxy/build/ahxy.phar/app/common/middleware/ActionHook.php(40): Webman\\App::Webman\\{closure}()
#7 phar:///mnt/c/Users/hushu/Desktop/XXXXXX/project/server/dev/ahxy/build/ahxy.phar/vendor/workerman/webman-framework/src/App.php(227): app\\common\\middleware\\ActionHook->process()
#8 phar:///mnt/c/Users/hushu/Desktop/XXXXXX/project/server/dev/ahxy/build/ahxy.phar/vendor/workerman/webman-framework/src/App.php(312): Webman\\App::Webman\\{closure}()
#9 phar:///mnt/c/Users/hushu/Desktop/XXXXXX/project/server/dev/ahxy/build/ahxy.phar/vendor/workerman/webman-framework/src/App.php(144): Webman\\App::findRoute()
#10 phar:///mnt/c/Users/hushu/Desktop/XXXXXX/project/server/dev/ahxy/build/ahxy.phar/vendor/workerman/workerman/Connection/TcpConnection.php(638): Webman\\App->onMessage()
#11 [internal function]: Workerman\\Connection\\TcpConnection->baseRead()
#12 phar:///mnt/c/Users/hushu/Desktop/XXXXXX/project/server/dev/ahxy/build/ahxy.phar/vendor/workerman/workerman/Events/Event.php(193): EventBase->loop()
#13 phar:///mnt/c/Users/hushu/Desktop/XXXXXX/project/server/dev/ahxy/build/ahxy.phar/vendor/workerman/workerman/Worker.php(2431): Workerman\\Events\\Event->loop()
#14 phar:///mnt/c/Users/hushu/Desktop/XXXXXX/project/server/dev/ahxy/build/ahxy.phar/vendor/workerman/workerman/Worker.php(1555): Workerman\\Worker->run()
#15 phar:///mnt/c/Users/hushu/Desktop/XXXXXX/project/server/dev/ahxy/build/ahxy.phar/vendor/workerman/workerman/Worker.php(1397): Workerman\\Worker::forkOneWorkerForLinux()
#16 phar:///mnt/c/Users/hushu/Desktop/XXXXXX/project/server/dev/ahxy/build/ahxy.phar/vendor/workerman/workerman/Worker.php(1371): Workerman\\Worker::forkWorkersForLinux()
#17 phar:///mnt/c/Users/hushu/Desktop/XXXXXX/project/server/dev/ahxy/build/ahxy.phar/vendor/workerman/workerman/Worker.php(549): Workerman\\Worker::forkWorkers()
#18 phar:///mnt/c/Users/hushu/Desktop/XXXXXX/project/server/dev/ahxy/build/ahxy.phar/vendor/webman/console/src/Application.php(93): Workerman\\Worker::runAll()
#19 phar:///mnt/c/Users/hushu/Desktop/XXXXXX/project/server/dev/ahxy/build/ahxy.phar/vendor/webman/console/src/Commands/StartCommand.php(31): Webman\\Console\\Application::run()
#20 phar:///mnt/c/Users/hushu/Desktop/XXXXXX/project/server/dev/ahxy/build/ahxy.phar/vendor/symfony/console/Command/Command.php(298): Webman\\Console\\Commands\\StartCommand->execute()
#21 phar:///mnt/c/Users/hushu/Desktop/XXXXXX/project/server/dev/ahxy/build/ahxy.phar/vendor/symfony/console/Application.php(1015): Symfony\\Component\\Console\\Command\\Command->run()
#22 phar:///mnt/c/Users/hushu/Desktop/XXXXXX/project/server/dev/ahxy/build/ahxy.phar/vendor/symfony/console/Application.php(299): Symfony\\Component\\Console\\Application->doRunCommand()
#23 phar:///mnt/c/Users/hushu/Desktop/XXXXXX/project/server/dev/ahxy/build/ahxy.phar/vendor/symfony/console/Application.php(171): Symfony\\Component\\Console\\Application->doRun()
#24 phar:///mnt/c/Users/hushu/Desktop/XXXXXX/project/server/dev/ahxy/build/ahxy.phar/webman(14): Symfony\\Component\\Console\\Application->run()
#25 /mnt/c/Users/hushu/Desktop/XXXXXX/project/server/dev/ahxy/build/ahxy.phar(5): require('phar:///mnt/c/U...')
#26 {main}"} []
1838 2 3
2个回答

walkor

最简单的办法是把public目录挪出来,当作普通目录使用,不打包进去。

更改 support/helper.php 中的

function public_path()
{
    return BASE_PATH . DIRECTORY_SEPARATOR . 'public';
}

function public_path()
{
    return \Phar::running() ? pathinfo(\Phar::running(false), PATHINFO_DIRNAME) . '/public' : realpath(base_path() . '/../public');
}

然后把 public目录移动到与 webman.phar 文件平行的位置。

.
├── public
└── webman.phar
  • 暂无评论
yanghang

webman admin 的插件静态资源按这个方式能处理吗

  • 暂无评论
年代过于久远,无法发表回答
🔝