Laravel File Storage – 永夜 https://www.shuijingwanwq.com 没有不值得去解决的问题,也没有不值得去学习的技术! Fri, 15 May 2026 10:31:39 +0000 zh-Hans hourly 1 https://wordpress.org/?v=7.0 Class “Vtiful\Kernel\Excel” not found,php-ext-xlswriter 使用过程中的问题排查 https://www.shuijingwanwq.com/2024/03/07/8459/ https://www.shuijingwanwq.com/2024/03/07/8459/#respond Thu, 07 Mar 2024 01:56:23 +0000 https://www.shuijingwanwq.com/?p=8459 浏览量: 242 1、报错:Class “Vtiful\Kernel\Excel” not found。 2、原因在于扩展 php-ext-xlswriter 未安装。 3、GitHub Release:https://github.com/viest/php-ext-xlswriter/releases 下载 php-windows-xlswriter-cf7e1933-8.1-ts-vs16-x64.zip 。如图1
GitHub Release:https://github.com/viest/php-ext-xlswriter/releases 下载 php-windows-xlswriter-cf7e1933-8.1-ts-vs16-x64.zip

图1

4、解压缩后,复制 php_xlswriter.dll 至 C:\php-8.1.27\ext\php_xlswriter.dll 5、编辑 php.ini,添加 extension=xlswriter 6、重启 PHP 后,再次报错:[ERROR] workbook_close(): Error creating ‘E:\wwwroot\object\storage\app\export/order/订单导出任务2024-02-19 10:24:06.xls’. Error = No error。如图2
重启 PHP 后,再次报错:[ERROR] workbook_close(): Error creating 'E:\wwwroot\object\storage\app\export/order/订单导出任务2024-02-19 10:24:06.xls'. Error = No error

图2

7、查看表 failed_jobs 中的异常详细信息:ErrorException: fopen(E:\wwwroot\object\storage\app\export/order/订单导出任务2024-02-19 10:24:06.xls): Failed to open stream: No such file or directory in


	$path = Storage::disk($this->disk)->putFileAs(
		$this->basePath,
		$this->excel->output(),
		basename($this->excel->{'localFileName'})
	);




ErrorException: fopen(E:\wwwroot\object\storage\app\export/order/订单导出任务2024-02-19 10:24:06.xls): Failed to open stream: No such file or directory in E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Filesystem\FilesystemAdapter.php:396
Stack trace:
#0 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\HandleExceptions.php(259): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'fopen(E:\\wwwroo...', 'E:\\wwwroot\\erp-...', 396)
#1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->Illuminate\Foundation\Bootstrap\{closure}(2, 'fopen(E:\\wwwroo...', 'E:\\wwwroot\\erp-...', 396)
#2 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Filesystem\FilesystemAdapter.php(396): fopen('E:\\wwwroot\\erp-...', 'r')
#3 E:\wwwroot\object\app\Services\ExportService.php(81): Illuminate\Filesystem\FilesystemAdapter->putFileAs('export/order', 'E:\\wwwroot\\erp-...', '\xE8\xAE\xA2\xE5\x8D\x95\xE5\xAF\xBC\xE5\x87\xBA\xE4\xBB\xBB...')
#4 E:\wwwroot\object\Modules\Order\Services\OrderExportService.php(593): App\Services\ExportService->save()
#5 E:\wwwroot\object\Modules\Order\Services\OrderExportService.php(230): Modules\Order\Services\OrderExportService->exportCheck(Array, Array, '\xE8\xAE\xA2\xE5\x8D\x95\xE5\xAF\xBC\xE5\x87\xBA\xE4\xBB\xBB...')
#6 E:\wwwroot\object\Modules\Order\Jobs\OrderExportJob.php(52): Modules\Order\Services\OrderExportService->exportOrderExcel(Array, Object(App\Models\JobStatus))
#7 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(36): Modules\Order\Jobs\OrderExportJob->handle()
#8 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Container\Util.php(41): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#9 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure(Object(Closure))
#10 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(37): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#11 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Container\Container.php(651): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#12 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Bus\Dispatcher.php(128): Illuminate\Container\Container->call(Array)
#13 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(141): Illuminate\Bus\Dispatcher->Illuminate\Bus\{closure}(Object(Modules\Order\Jobs\OrderExportJob))
#14 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(116): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Modules\Order\Jobs\OrderExportJob))
#15 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Bus\Dispatcher.php(132): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#16 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Queue\CallQueuedHandler.php(124): Illuminate\Bus\Dispatcher->dispatchNow(Object(Modules\Order\Jobs\OrderExportJob), false)
#17 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(141): Illuminate\Queue\CallQueuedHandler->Illuminate\Queue\{closure}(Object(Modules\Order\Jobs\OrderExportJob))
#18 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(116): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Modules\Order\Jobs\OrderExportJob))
#19 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Queue\CallQueuedHandler.php(126): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#20 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Queue\CallQueuedHandler.php(70): Illuminate\Queue\CallQueuedHandler->dispatchThroughMiddleware(Object(Illuminate\Queue\Jobs\RedisJob), Object(Modules\Order\Jobs\OrderExportJob))
#21 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Queue\Jobs\Job.php(98): Illuminate\Queue\CallQueuedHandler->call(Object(Illuminate\Queue\Jobs\RedisJob), Array)
#22 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Queue\Worker.php(425): Illuminate\Queue\Jobs\Job->fire()
#23 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Queue\Worker.php(375): Illuminate\Queue\Worker->process('redis', Object(Illuminate\Queue\Jobs\RedisJob), Object(Illuminate\Queue\WorkerOptions))
#24 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Queue\Worker.php(173): Illuminate\Queue\Worker->runJob(Object(Illuminate\Queue\Jobs\RedisJob), 'redis', Object(Illuminate\Queue\WorkerOptions))
#25 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Queue\Console\WorkCommand.php(150): Illuminate\Queue\Worker->daemon('redis', 'export_queue', Object(Illuminate\Queue\WorkerOptions))
#26 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Queue\Console\WorkCommand.php(134): Illuminate\Queue\Console\WorkCommand->runWorker('redis', 'export_queue')
#27 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(36): Illuminate\Queue\Console\WorkCommand->handle()
#28 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Container\Util.php(41): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#29 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure(Object(Closure))
#30 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(37): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#31 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Container\Container.php(651): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#32 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Console\Command.php(144): Illuminate\Container\Container->call(Array)
#33 E:\wwwroot\object\vendor\symfony\console\Command\Command.php(312): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#34 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Console\Command.php(126): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#35 E:\wwwroot\object\vendor\symfony\console\Application.php(1022): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#36 E:\wwwroot\object\vendor\symfony\console\Application.php(314): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#37 E:\wwwroot\object\vendor\symfony\console\Application.php(168): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#38 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Console\Application.php(102): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#39 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php(151): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#40 E:\wwwroot\object\artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#41 {main}


8、决定从 PHP 官网下载:https://pecl.php.net/package/xlswriter/1.5.1/windows 。8.1 Thread Safe (TS) x64。 9、报错:Worksheet row or column index out of range. 参考:异常码列表 。https://xlswriter-docs.viest.me/zh-cn/exception/code 。工作表的行或列索引超出Excel规定范围,请检查数组键值。如图3
报错:Worksheet row or column index out of range. 参考:异常码列表 。https://xlswriter-docs.viest.me/zh-cn/exception/code 。工作表的行或列索引超出Excel规定范围,请检查数组键值

图3



Vtiful\Kernel\Exception: Worksheet row or column index out of range. in E:\wwwroot\object\app\Services\ExportService.php:107
Stack trace:
#0 E:\wwwroot\object\app\Services\ExportService.php(107): Vtiful\Kernel\Excel->data(Array)
#1 E:\wwwroot\object\Modules\Order\Services\OrderExportService.php(581): App\Services\ExportService->writeRows(Array)
#2 E:\wwwroot\object\Modules\Order\Services\OrderExportService.php(230): Modules\Order\Services\OrderExportService->exportCheck(Array, Array, '\xE8\xAE\xA2\xE5\x8D\x95\xE5\xAF\xBC\xE5\x87\xBA\xE4\xBB\xBB...')
#3 E:\wwwroot\object\Modules\Order\Jobs\OrderExportJob.php(52): Modules\Order\Services\OrderExportService->exportOrderExcel(Array, Object(App\Models\JobStatus))
#4 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(36): Modules\Order\Jobs\OrderExportJob->handle()
#5 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Container\Util.php(41): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#6 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure(Object(Closure))
#7 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(37): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#8 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Container\Container.php(651): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#9 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Bus\Dispatcher.php(128): Illuminate\Container\Container->call(Array)
#10 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(141): Illuminate\Bus\Dispatcher->Illuminate\Bus\{closure}(Object(Modules\Order\Jobs\OrderExportJob))
#11 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(116): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Modules\Order\Jobs\OrderExportJob))
#12 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Bus\Dispatcher.php(132): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#13 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Queue\CallQueuedHandler.php(124): Illuminate\Bus\Dispatcher->dispatchNow(Object(Modules\Order\Jobs\OrderExportJob), false)
#14 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(141): Illuminate\Queue\CallQueuedHandler->Illuminate\Queue\{closure}(Object(Modules\Order\Jobs\OrderExportJob))
#15 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(116): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Modules\Order\Jobs\OrderExportJob))
#16 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Queue\CallQueuedHandler.php(126): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#17 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Queue\CallQueuedHandler.php(70): Illuminate\Queue\CallQueuedHandler->dispatchThroughMiddleware(Object(Illuminate\Queue\Jobs\RedisJob), Object(Modules\Order\Jobs\OrderExportJob))
#18 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Queue\Jobs\Job.php(98): Illuminate\Queue\CallQueuedHandler->call(Object(Illuminate\Queue\Jobs\RedisJob), Array)
#19 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Queue\Worker.php(425): Illuminate\Queue\Jobs\Job->fire()
#20 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Queue\Worker.php(375): Illuminate\Queue\Worker->process('redis', Object(Illuminate\Queue\Jobs\RedisJob), Object(Illuminate\Queue\WorkerOptions))
#21 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Queue\Worker.php(173): Illuminate\Queue\Worker->runJob(Object(Illuminate\Queue\Jobs\RedisJob), 'redis', Object(Illuminate\Queue\WorkerOptions))
#22 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Queue\Console\WorkCommand.php(150): Illuminate\Queue\Worker->daemon('redis', 'export_queue', Object(Illuminate\Queue\WorkerOptions))
#23 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Queue\Console\WorkCommand.php(134): Illuminate\Queue\Console\WorkCommand->runWorker('redis', 'export_queue')
#24 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(36): Illuminate\Queue\Console\WorkCommand->handle()
#25 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Container\Util.php(41): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#26 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure(Object(Closure))
#27 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(37): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#28 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Container\Container.php(651): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#29 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Console\Command.php(144): Illuminate\Container\Container->call(Array)
#30 E:\wwwroot\object\vendor\symfony\console\Command\Command.php(312): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#31 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Console\Command.php(126): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#32 E:\wwwroot\object\vendor\symfony\console\Application.php(1022): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#33 E:\wwwroot\object\vendor\symfony\console\Application.php(314): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#34 E:\wwwroot\object\vendor\symfony\console\Application.php(168): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#35 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Console\Application.php(102): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#36 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php(151): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#37 E:\wwwroot\object\artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#38 {main}

Next Vtiful\Kernel\Exception: Worksheet row or column index out of range. in E:\wwwroot\object\app\Services\ExportService.php:107
Stack trace:
#0 E:\wwwroot\object\app\Services\ExportService.php(107): Vtiful\Kernel\Excel->data(Array)
#1 E:\wwwroot\object\Modules\Order\Services\OrderExportService.php(581): App\Services\ExportService->writeRows(Array)
#2 E:\wwwroot\object\Modules\Order\Services\OrderExportService.php(230): Modules\Order\Services\OrderExportService->exportCheck(Array, Array, '\xE8\xAE\xA2\xE5\x8D\x95\xE5\xAF\xBC\xE5\x87\xBA\xE4\xBB\xBB...')
#3 E:\wwwroot\object\Modules\Order\Jobs\OrderExportJob.php(52): Modules\Order\Services\OrderExportService->exportOrderExcel(Array, Object(App\Models\JobStatus))
#4 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(36): Modules\Order\Jobs\OrderExportJob->handle()
#5 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Container\Util.php(41): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#6 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure(Object(Closure))
#7 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(37): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#8 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Container\Container.php(651): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#9 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Bus\Dispatcher.php(128): Illuminate\Container\Container->call(Array)
#10 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(141): Illuminate\Bus\Dispatcher->Illuminate\Bus\{closure}(Object(Modules\Order\Jobs\OrderExportJob))
#11 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(116): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Modules\Order\Jobs\OrderExportJob))
#12 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Bus\Dispatcher.php(132): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#13 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Queue\CallQueuedHandler.php(124): Illuminate\Bus\Dispatcher->dispatchNow(Object(Modules\Order\Jobs\OrderExportJob), false)
#14 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(141): Illuminate\Queue\CallQueuedHandler->Illuminate\Queue\{closure}(Object(Modules\Order\Jobs\OrderExportJob))
#15 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(116): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Modules\Order\Jobs\OrderExportJob))
#16 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Queue\CallQueuedHandler.php(126): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#17 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Queue\CallQueuedHandler.php(70): Illuminate\Queue\CallQueuedHandler->dispatchThroughMiddleware(Object(Illuminate\Queue\Jobs\RedisJob), Object(Modules\Order\Jobs\OrderExportJob))
#18 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Queue\Jobs\Job.php(98): Illuminate\Queue\CallQueuedHandler->call(Object(Illuminate\Queue\Jobs\RedisJob), Array)
#19 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Queue\Worker.php(425): Illuminate\Queue\Jobs\Job->fire()
#20 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Queue\Worker.php(375): Illuminate\Queue\Worker->process('redis', Object(Illuminate\Queue\Jobs\RedisJob), Object(Illuminate\Queue\WorkerOptions))
#21 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Queue\Worker.php(173): Illuminate\Queue\Worker->runJob(Object(Illuminate\Queue\Jobs\RedisJob), 'redis', Object(Illuminate\Queue\WorkerOptions))
#22 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Queue\Console\WorkCommand.php(150): Illuminate\Queue\Worker->daemon('redis', 'export_queue', Object(Illuminate\Queue\WorkerOptions))
#23 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Queue\Console\WorkCommand.php(134): Illuminate\Queue\Console\WorkCommand->runWorker('redis', 'export_queue')
#24 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(36): Illuminate\Queue\Console\WorkCommand->handle()
#25 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Container\Util.php(41): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#26 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure(Object(Closure))
#27 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(37): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#28 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Container\Container.php(651): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#29 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Console\Command.php(144): Illuminate\Container\Container->call(Array)
#30 E:\wwwroot\object\vendor\symfony\console\Command\Command.php(312): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#31 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Console\Command.php(126): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#32 E:\wwwroot\object\vendor\symfony\console\Application.php(1022): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#33 E:\wwwroot\object\vendor\symfony\console\Application.php(314): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#34 E:\wwwroot\object\vendor\symfony\console\Application.php(168): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#35 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Console\Application.php(102): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#36 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php(151): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#37 E:\wwwroot\object\artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#38 {main}



10、最终发现原因在于:$this->excel->data($data); $data 的数组为关联数组所导致。当为索引数组后,不再报错:Worksheet row or column index out of range.。继续报错:[ERROR] workbook_close(): Error creating。最终决定不修改代码,继续使用 php-windows-xlswriter-cf7e1933-8.1-ts-vs16-x64,就自动兼容了关联数组。


[
  {
    "plat_order_no": "GM20240204031613_3",
    "transaction_no": "202402041"
  }
]




[
  [
    "GM20240204031613_3",
    "202402041"
  ]
]


11、最终找到直接原因,在于 output() 时,Excel 文件未生成成功。根本原因在于 fileName(); 的参数中包含了 : ,进而导致 Excel 文件未生成。将一个 xls 文件重命名为:订单导出任务2024-02-19 17:42:32,会自动调整为:订单导出任务2024-02-19 174232。提示:文件名不能包含下列任何字符: \\:*?”<<>| 。如图4
最终找到直接原因,在于 output() 时,Excel 文件未生成成功。根本原因在于 fileName(); 的参数中包含了 : ,进而导致 Excel 文件未生成。将一个 xls 文件重命名为:订单导出任务2024-02-19 17:42:32,会自动调整为:订单导出任务2024-02-19 174232。提示:文件名不能包含下列任何字符: \\:*?"<<>|

图4

12、将文件名中的 : 替换为 _ 后。导出 Excel 文件成功。]]>
https://www.shuijingwanwq.com/2024/03/07/8459/feed/ 0
在 Windows 10 中,一个 ZIP 压缩文件(基于 ZipStream PHP),基于 360 压缩解压成功,基于 WinRAR 解压缩失败 https://www.shuijingwanwq.com/2023/04/27/7591/ https://www.shuijingwanwq.com/2023/04/27/7591/#respond Thu, 27 Apr 2023 01:38:48 +0000 https://www.shuijingwanwq.com/?p=7591 浏览量: 85 1、参考:在 Laravel 6 中基于 ZipStream PHP ,将 zip 文件流式传输到 S3 存储桶。参考:在 PHP 7.4 中基于 fopen 生成一个流资源,操作了磁盘,调整为完全基于内存的实现。基于 360 压缩解压成功,基于 WinRAR 解压缩失败。如图1
参考:在 Laravel 6 中基于 ZipStream PHP ,将 zip 文件流式传输到 S3 存储桶。参考:在 PHP 7.4 中基于 fopen 生成一个流资源,操作了磁盘,调整为完全基于内存的实现。基于 360 压缩解压成功,基于 WinRAR 解压缩失败。

图1

2、在 Linux 上用 7z 进行解压,虽然能解压出来,但是其实还是有报错信息。如图2
在 Linux 上用 7z 进行解压,虽然能解压出来,但是其实还是有报错信息

图2



ERRORS:
Unexpected end of archive

--
Path = assets_new.zip
Type = zip
ERRORS:
Unexpected end of archive
Physical Size = 781844



Archives with Errors: 1

Open Errors: 1


3、参考:https://maennchen.dev/ZipStream-PHP/guide/FlySystem.html 。在上传流之前,需要先执行:$zip->finish(); 调整前:


        $name = $this->themeInstallationTask->themeInstallation->theme_id . '/assets.zip';

        $stream = fopen('php://memory', 'w+');
        $options = new Archive();
        $options->setOutputStream($stream);
        $zip = new ZipStream($name, $options);

		$zip->addFile(str_replace('\\', '/', str_replace(self::$destination . '/', '', $file->getPathname())), $file->getContents());

        Storage::disk(config('theme_asset.filesystem.disk'))->putStream(
            $name,
            $stream,
            config('theme_asset.filesystem.options')
        );
		
		$zip->finish();
        fclose($stream);


调整后:


        $name = $this->themeInstallationTask->themeInstallation->theme_id . '/assets.zip';

        $stream = fopen('php://memory', 'w+');
        $options = new Archive();
        $options->setOutputStream($stream);
        $zip = new ZipStream($name, $options);

		$zip->addFile(str_replace('\\', '/', str_replace(self::$destination . '/', '', $file->getPathname())), $file->getContents());

        $zip->finish();

        Storage::disk(config('theme_asset.filesystem.disk'))->putStream(
            $name,
            $stream,
            config('theme_asset.filesystem.options')
        );
		
        fclose($stream);


4、基于 360 压缩解压成功,基于 WinRAR 解压缩成功。]]>
https://www.shuijingwanwq.com/2023/04/27/7591/feed/ 0
在 Laravel 6 中基于 ZipStream PHP ,将 zip 文件流式传输到 S3 存储桶 https://www.shuijingwanwq.com/2023/04/18/7554/ https://www.shuijingwanwq.com/2023/04/18/7554/#respond Tue, 18 Apr 2023 01:36:57 +0000 https://www.shuijingwanwq.com/?p=7554 浏览量: 83 1、当在请求 S3 存储桶时,遇到了限流问题:Please reduce your request rate,进而导致请求失败。如图1
当在请求 S3 存储桶时,遇到了限流问题:Please reduce your request rate,进而导致请求失败

图1

2、最终实现代码如下


$name = $themeId . '/assets.zip';

$zip = new ZipStream($name);

$zip->addFile('apps/internal/back-top/assets/app.9ce8af2.js', '0000000000000');

$res = Storage::disk(config('theme_asset.filesystem.disk'))->put(
	$name,
	$zip->finish(),
	config('theme_asset.filesystem.options')
);


3、在浏览器中打开 S3 对应的 CDN 地址:https://xxx.cloudfastin.com/static/xxx/98cb73f9-e61a-40b1-a27a-3beb99015e5e/assets.zip 。文件可下载,确认文件上传至 S3 成功。如图2
在浏览器中打开 S3 对应的 CDN 地址:https://themes-statics-test.cloudfastin.com/static/xxx/98cb73f9-e61a-40b1-a27a-3beb99015e5e/assets.zip 。文件可下载,确认文件上传至 S3 成功

图2

3、将下载后的文件解压缩,失败,提示:该文件为非压缩文件,无法打开。如图3
将下载后的文件解压缩,失败,提示:该文件为非压缩文件,无法打开

图3

4、使用 putStream 方法,且设置 ZipStream 对象的选项中,输出流。下载后,解压缩成功。如图4
使用 putStream 方法,且设置 ZipStream 对象的选项中,输出流。下载后,解压缩成功

图4



$name = $themeId . '/assets.zip';

$tmp = tempnam(sys_get_temp_dir(), 'zip_stream');
$stream = fopen($tmp, 'w+');

$options = new Archive();
//$options->setContentType('application/x-zip-compressed');
$options->setOutputStream($stream);
$zip = new ZipStream($name, $options);

$zip = new ZipStream($name);

$zip->addFile('apps/internal/back-top/assets/app.9ce8af2.js', '0000000000000');

$zip->finish();

$res = Storage::disk(config('theme_asset.filesystem.disk'))->putStream(
	$name,
	$stream,
	config('theme_asset.filesystem.options')
);


fclose($stream);


5、但是,如果路径中包含反斜杠,例,路径为:css\app.6156ec.css 的文件,其路径已经变化为:css_app.6156ec.css。如图5
但是,如果路径中包含反斜杠,例,路径为:css\app.6156ec.css 的文件,其路径已经变化为:css_app.6156ec.css

图5

6、需要将 路径为:css\app.6156ec.css 的文件,替换为:css/app.6156ec.css。上传至 S3,下载后解压缩,目录结构正常。如图6
需要将 路径为:css\app.6156ec.css 的文件,替换为:css/app.6156ec.css。上传至 S3,下载后解压缩,目录结构正常

图6



$zip->addFile(str_replace('\\', '/', 'css\\app.6156ec.css'), $file->getContents());


]]>
https://www.shuijingwanwq.com/2023/04/18/7554/feed/ 0