Search code examples
phplaravelamazon-web-servicesamazon-s3phpword

How to open templates from S3 in phpword?


I want to move away from using my ec2 instance to store users word templates as they get removed with each deployed version. I've setup my s3 bucket in laravel and can store files on it successfully. However I don't know how to load them into phpword.

 $templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor(storage_path('app/templates/' . $company->id . '.docx'));

The above code is how I would previously load my template using the local disk, this constructor wants a string path to the file. From the laravel documentation I can see that I need to use the storage facade but I don't think Storage::get() or Storage::Url() will work.


Solution

  • I eventually solved this by copying the file from my s3 instance to my ec2 instance before using phpword