My API call is taking too long to complete as after operation completion it calls php_curl to extenal server for sending SMS and another extenal SMTP server to send Email and I might integrate WhatApps API to send message in future.
What I want to do is send / flush response once operation completes
and Do the post processing to send SMS/ Email / Whatsapp later.
<?php
use \Psr\Container\ContainerInterface as ContainerInterface;
class SomeController
{
protected $container;
public function __construct(ContainerInterface $container) {
$this->container = $container;
}
public function save($request, $response, $args) {
$dataService = new SomeService($request);
$dataService->saveSome();
$opResponse = $dataService->getReponse();
// HOW TO ACHIEVE THIS IN SLIM
$opResponse->flush()->end();
if($opResponse->succes = TRUE){
$smsService = new SMS($opResponse);
$smsService->sendSaveSMS();
$mailService = new Email($opResponse);
$mailService->sendSaveEmail();
$waService = new Whatsapp($opResponse);
$waService->sendSaveWhatsapp();
}
}
}
?>