I made a PHP library that implements a method to achieve just that, it's built for Laravel but you could just copy the logic and use it in any PHP application. https://packagist.org/packages/oliverlundquist/laravel-http-background