Skip to content
This repository was archived by the owner on Feb 11, 2020. It is now read-only.

Latest commit

 

History

History
58 lines (43 loc) · 2.88 KB

File metadata and controls

58 lines (43 loc) · 2.88 KB
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.