Hey again,
I appologize in advance but i've been looking at all the examples and the other related topics from the forum but i still dont understand how to stream a docx from an api and retrieve it from another app. Would it be possible to have an actual fully working example ideally with symfony.
here is what i got so far:
The API endpoint
use Phpdocx\Create\CreateDocx; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\StreamedResponse; use Symfony\Component\Routing\Annotation\Route; class AppController extends AbstractController { #[Route('/', name: 'app_app')] public function index(): StreamedResponse { $doc = new CreateDocx(); CreateDocx::$streamMode = true; $doc->addText('This is a test'); $doc->embedHTML('<p style="font-size: 30px;">New paragraph</p>'); return new StreamedResponse(function () use ($doc) { $doc->createDocx('output1'); }); } }
and the front.
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; use Symfony\Contracts\HttpClient\HttpClientInterface; class AppController extends AbstractController { #[Route('/', name: 'app_home')] public function index(HttpClientInterface $http): Response { $response = $http->request(Request::METHOD_GET, 'https://dev.doc.ey'); $doc = $response->getContent(); dd($doc); return $this->render('app/index.html.twig', [ 'controller_name' => 'AppController', ]); } }