stephenlake/php-covert

This package is abandoned and no longer maintained. No replacement package was suggested.

Process background PHP tasks.

v0.0.4 2019-08-23 10:01 UTC

This package is auto-updated.

Last update: 2020-02-12 23:11:14 UTC


README

php-covert-banner.png
Execute code as a background system process for Linux, Mac and Windows without relying on any external dependencies.

Build Status StyleCI Release License


PHP Covert

PHP Covert makes running inline code as background tasks in PHP a piece of cake without the need to install external software nor enable additional extensions. Plan your operation and execute it instantly as a background process.

Made with ❤️ by Stephen Lake. Maintained with ❤️ by Paweł Kłopotek-Główczewski.

Disclaimer

This package does not make use of threading and is not intended to replace queues/workers, it's more of a hack than anything and is not the 'proper' way to schedule tasks nor run them in the background. This package was created as an experiment and published due to the frequently asked questions of 'how to run a PHP task in the background'.

Getting Started

Install the package via composer.

composer require stephenlake/php-covert

Try it!

use Covert\Operation;

$operation = new Operation();
$operation->setLoggingFile('log.txt');
$operation->execute(function() {
     $counter = 0;
     
     while($counter < 120) {
        $counter++;
        sleep(1);
        echo "I have been running in the background for {$counter} seconds!".PHP_EOL;
     }
});

// Continue with your app's logic here while your background task is running

That's it. Your task is now running in the background as a process. Get the process ID with $operation->getProcessID(). Check out the documentation for further usage and features.

License

This library is licensed under the MIT License - see the LICENSE.md file for details.