相关疑难解决方法(0)

发送http响应后继续处理php

我的脚本由服务器调用.从服务器我会收到ID_OF_MESSAGETEXT_OF_MESSAGE.

在我的脚本中,我将处理传入的文本并使用params生成响应:ANSWER_TO_IDRESPONSE_MESSAGE.

问题是我正在向incomming发送响应"ID_OF_MESSAGE",但是在收到http响应200之后,向我发送消息的服务器将把他的消息设置为发送给我(这意味着我可以发送给他的响应).

解决方案之一是将消息保存到数据库并制作一些将每分钟运行的cron,但我需要立即生成响应消息.

是否有一些解决方案如何发送到服务器http响应200而不是继续执行PHP脚本?

非常感谢

php http response

91
推荐指数
7
解决办法
6万
查看次数

Symfony在发送响应后运行代码

我看了看这个问题.我正在寻找一种方法来做那个问题的OP也想要的,那就是在发送http响应之后继续处理php,但是在Symfony2中.

我实现了一个在每次内核终止后触发的事件.到目前为止一切都那么好,但我想要的是它在CERTAIN终止后,在特定的控制器动作中触发,例如在发送表单之后,而不是每次请求时.这是因为我想在某些时候做一些繁重的任务,并且不希望最终用户等待页面加载.

知道我该怎么办?

<?php


namespace MedAppBundle\Event;

use JMS\DiExtraBundle\Annotation\InjectParams;
use JMS\DiExtraBundle\Annotation\Service;
use JMS\DiExtraBundle\Annotation\Tag;
use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\Console\ConsoleEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use JMS\DiExtraBundle\Annotation\Inject;
/**
 * Class MedicListener
 * @package MedAppBundle\EventListener
 * @Service("medapp_test.listener")
 * @Tag(name="kernel.event_subscriber")
 */
class TestListener implements EventSubscriberInterface
{
    private $container;

    private $logger;

    /**
     * Constructor.
     *
     * @param ContainerInterface $container A ContainerInterface instance
     * @param LoggerInterface $logger A LoggerInterface instance
     * @InjectParams({
     *     "container" = @Inject("service_container"),
     *     "logger" = @Inject("logger")
     * })
     */ …
Run Code Online (Sandbox Code Playgroud)

php httpresponse symfony

9
推荐指数
1
解决办法
6663
查看次数

标签 统计

php ×2

http ×1

httpresponse ×1

response ×1

symfony ×1