ambientia / queue-command
Provides asynchronous queue for Symfony projects
Installs: 1 323
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 0
Requires
- php: 7.4.*
- doctrine/orm: ^2.8
- psr/container: ^1.0
- psr/event-dispatcher: ^1.0
- symfony/event-dispatcher: ^5.0
- symfony/lock: ^5.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.15
- phan/phan: ^2.2
- phpunit/phpunit: ^9.5
Suggests
- alphpkeemik/data-cleaner: Helper to automatically remove processed rows from database
README
PHP library for executing queued commands
usage
Adding to queue
<?php
use Ambientia\QueueCommand\QueueCommandEntity;
use App\MyModule\MyService;
use Doctrine\Common\Persistence\ObjectManager;
$queueCommand = new QueueCommandEntity();
$queueCommand->setService(MyService::class);
/** @var ObjectManager $entityManager */
$entityManager->persist($queueCommand);
$entityManager->flush();
Creating queue command
<?php
namespace App\MyModule;
class MyService
{
public function execute(int $arg1)
{
//do some stuff
$result = $arg1 + 1;
// return some message if needed
return "$arg1 processed ro $result";
}
}
Add cron
* * * * * ambientia:queue-command:execute >> /path/to/log/file 2>&1
add data cleaner
https://github.com/alphpkeemik/data-cleaner
development
Run docker docker-composer up -d
Bash to container docker/bash.sh
todo
- remove container dependency
- todo replace merge it with find in EntityProcessor
- todo add waiting / persistent running
- add data cleaner interface
Running code fixer
Run php cs fixer ./vendor/bin/php-cs-fixer fix
Running the tests
Run tests with phpunit ./vendor/bin/phpunit
Running analyzer
Run phan ./vendor/bin/phan