diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 1344a5d..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,29 +0,0 @@
-language: php
-php:
- - 7.1
- - 7.3
-
-before_script:
- - composer install
-
-matrix:
- fast_finish: true
- include:
- - php: 7.1
- env: SYMFONY_VERSION=4.0.*
- - php: 7.3
- env: SYMFONY_VERSION=4.4.* DEPENDENCIES=beta
-
-sudo: false
-
-cache:
- directories:
- - $HOME/.composer/cache
-
-before_install:
- - if [ "$DEPENDENCIES" = "beta" ]; then composer config minimum-stability beta; fi;
- - if [ "$SYMFONY_VERSION" != "" ]; then composer require "symfony/framework-bundle:${SYMFONY_VERSION}" --no-update; fi;
- - if [ "$SYMFONY_VERSION" != "" ]; then composer require "symfony/console:${SYMFONY_VERSION}" --no-update; fi;
- - if [ "$SYMFONY_VERSION" != "" ]; then composer require "symfony/process:${SYMFONY_VERSION}" --no-update; fi;
-
-install: composer update --prefer-dist --no-interaction $COMPOSER_FLAGS
diff --git a/Command/CleanUpWorkersCommand.php b/Command/CleanUpWorkersCommand.php
index fdf7e91..a118e26 100644
--- a/Command/CleanUpWorkersCommand.php
+++ b/Command/CleanUpWorkersCommand.php
@@ -8,29 +8,23 @@
namespace ResqueBundle\Resque\Command;
+use Symfony\Component\Console\Attribute\AsCommand;
use ResqueBundle\Resque\Resque;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
-/**
- * Class CleanUpWorkersCommand.
- */
+#[AsCommand(
+ name: 'resque:cleanup:workers',
+ description: 'Unregisters all workers in Redis. Workers may need to be restarted.',
+)]
class CleanUpWorkersCommand extends Command
{
- private $resque;
-
- public function __construct(string $name = null, Resque $resque)
- {
- $this->resque = $resque;
- parent::__construct($name);
- }
-
- protected function configure()
+ public function __construct(
+ private Resque $resque
+ )
{
- $this
- ->setName('resque:cleanup:workers')
- ->setDescription('Unregisters all workers in Redis. Workers may need to be restarted.');
+ parent::__construct();
}
/**
@@ -50,6 +44,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
}
- return 0;
+ return Command::SUCCESS;
}
}
diff --git a/Command/ClearQueueCommand.php b/Command/ClearQueueCommand.php
index c495ee2..1cacedd 100644
--- a/Command/ClearQueueCommand.php
+++ b/Command/ClearQueueCommand.php
@@ -8,31 +8,28 @@
namespace ResqueBundle\Resque\Command;
+use Symfony\Component\Console\Attribute\AsCommand;
use ResqueBundle\Resque\Resque;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
-/**
- * Class ClearQueueCommand.
- */
+#[AsCommand(
+ name: 'resque:clear-queue',
+ description: 'Clear a resque queue',
+)]
class ClearQueueCommand extends Command
{
- private $resque;
-
- public function __construct(string $name = null, Resque $resque)
+ public function __construct(
+ private Resque $resque)
{
- $this->resque = $resque;
- parent::__construct($name);
+ parent::__construct();
}
protected function configure()
{
- $this
- ->setName('resque:clear-queue')
- ->setDescription('Clear a resque queue')
- ->addArgument('queue', InputArgument::REQUIRED, 'Queue name');
+ $this->addArgument('queue', InputArgument::REQUIRED, 'Queue name');
}
/**
@@ -46,8 +43,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
$queue = $input->getArgument('queue');
$count = $this->resque->clearQueue($queue);
- $output->writeln('Cleared queue '.$queue.' - removed '.$count.' entries');
+ $output->writeln('Cleared queue ' . $queue . ' - removed ' . $count . ' entries');
- return 0;
+ return Command::SUCCESS;
}
}
diff --git a/Command/PingTestCommand.php b/Command/PingTestCommand.php
index eac111f..09181a0 100644
--- a/Command/PingTestCommand.php
+++ b/Command/PingTestCommand.php
@@ -8,30 +8,24 @@
namespace ResqueBundle\Resque\Command;
+use Symfony\Component\Console\Attribute\AsCommand;
use ResqueBundle\Resque\ExampleJobs\PingJob;
use ResqueBundle\Resque\Resque;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
-/**
- * Class PingTestCommand.
- */
+#[AsCommand(
+ name: 'resque:pingtest',
+ description: 'Send a Ping as a test, and let a job reply with pong',
+)]
class PingTestCommand extends Command
{
- private $resque;
-
- public function __construct(string $name = null, Resque $resque)
- {
- $this->resque = $resque;
- parent::__construct($name);
- }
-
- protected function configure()
+ public function __construct(
+ private Resque $resque
+ )
{
- $this
- ->setName('resque:pingtest')
- ->setDescription('Send a Ping as a test, and let a job reply with pong');
+ parent::__construct();
}
/**
@@ -45,6 +39,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
$job = new PingJob();
$output->writeln($this->resque->enqueue($job, true));
- return 0;
+ return Command::SUCCESS;
}
}
diff --git a/Command/StartScheduledWorkerCommand.php b/Command/StartScheduledWorkerCommand.php
index ad096a0..0ded1d7 100644
--- a/Command/StartScheduledWorkerCommand.php
+++ b/Command/StartScheduledWorkerCommand.php
@@ -8,6 +8,7 @@
namespace ResqueBundle\Resque\Command;
+use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
@@ -15,24 +16,21 @@
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Process\Process;
-/**
- * Class StartScheduledWorkerCommand.
- */
+#[AsCommand(
+ name: 'resque:scheduledworker-start',
+ description: 'Start a scheduled resque worker',
+)]
class StartScheduledWorkerCommand extends Command
{
- private $params;
-
- public function __construct(string $name = null, ParameterBagInterface $params)
+ public function __construct(
+ private ParameterBagInterface $params)
{
- $this->params = $params;
- parent::__construct($name);
+ parent::__construct();
}
protected function configure()
{
$this
- ->setName('resque:scheduledworker-start')
- ->setDescription('Start a scheduled resque worker')
->addOption('foreground', 'f', InputOption::VALUE_NONE, 'Should the worker run in foreground')
->addOption('force', null, InputOption::VALUE_NONE, 'Force creation of a new worker if the PID file exists')
->addOption('interval', 'i', InputOption::VALUE_REQUIRED, 'How often to check for new jobs across the queues', 5);
@@ -48,7 +46,7 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
- $pidFile = $this->params->get('kernel.cache_dir').'/resque_scheduledworker.pid';
+ $pidFile = $this->params->get('kernel.cache_dir') . '/resque_scheduledworker.pid';
if (file_exists($pidFile) && !$input->getOption('force')) {
throw new \Exception('PID file exists - use --force to override');
}
@@ -60,31 +58,31 @@ protected function execute(InputInterface $input, OutputInterface $output)
$env = [
'APP_INCLUDE' => $this->params->get('resque.app_include'),
'VVERBOSE' => 1,
- 'RESQUE_PHP' => $this->params->get('resque.vendor_dir').'/chrisboulton/php-resque/lib/Resque.php',
+ 'RESQUE_PHP' => $this->params->get('resque.vendor_dir') . '/chrisboulton/php-resque/lib/Resque.php',
'INTERVAL' => $input->getOption('interval'),
];
if (!file_exists($env['RESQUE_PHP'])) {
- $env['RESQUE_PHP'] = $this->params->get('resque.vendor_dir').'/resque/php-resque/lib/Resque.php';
+ $env['RESQUE_PHP'] = $this->params->get('resque.vendor_dir') . '/resque/php-resque/lib/Resque.php';
}
if (false !== getenv('APP_INCLUDE')) {
$env['APP_INCLUDE'] = getenv('APP_INCLUDE');
}
- $prefix = $this->params->get('resque.prefix');
+ $prefix = $this->params->get('resque.prefix');
if (!empty($prefix)) {
- $env['PREFIX'] = $this->params->get('resque.prefix');
+ $env['PREFIX'] = $this->params->get('resque.prefix');
}
- $redisHost = $this->params->get('resque.redis.host');
- $redisPort = $this->params->get('resque.redis.port');
- $redisDatabase = $this->params->get('resque.redis.database');
- $redisPassword = $this->params->get('resque.redis.password');
+ $redisHost = $this->params->get('resque.redis.host');
+ $redisPort = $this->params->get('resque.redis.port');
+ $redisDatabase = $this->params->get('resque.redis.database');
+ $redisPassword = $this->params->get('resque.redis.password');
if (null != $redisHost && null != $redisPort) {
- $env['REDIS_BACKEND'] = $redisHost.':'.$redisPort;
+ $env['REDIS_BACKEND'] = $redisHost . ':' . $redisPort;
}
if (isset($redisDatabase)) {
@@ -98,20 +96,20 @@ protected function execute(InputInterface $input, OutputInterface $output)
if (version_compare(PHP_VERSION, '5.4.0') >= 0) {
$phpExecutable = PHP_BINARY;
} else {
- $phpExecutable = PHP_BINDIR.'/php';
+ $phpExecutable = PHP_BINDIR . '/php';
if (\defined('PHP_WINDOWS_VERSION_BUILD')) {
$phpExecutable = 'php';
}
}
- $workdirectory = __DIR__.'/../bin/';
- $workerCommand = $phpExecutable.' '.$workdirectory.'resque-scheduler';
+ $workdirectory = __DIR__ . '/../bin/';
+ $workerCommand = $phpExecutable . ' ' . $workdirectory . 'resque-scheduler';
if (!$input->getOption('foreground')) {
- $logFile = $this->params->get(
+ $logFile = $this->params->get(
'kernel.logs_dir'
- ).'/resque-scheduler_'.$this->params->get('kernel.environment').'.log';
- $workerCommand = 'nohup '.$workerCommand.' > '.$logFile.' 2>&1 & echo $!';
+ ) . '/resque-scheduler_' . $this->params->get('kernel.environment') . '.log';
+ $workerCommand = 'nohup ' . $workerCommand . ' > ' . $logFile . ' 2>&1 & echo $!';
}
// In windows: When you pass an environment to CMD it replaces the old environment
@@ -119,7 +117,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
// this is a workaround where we add the vars to the existing environment.
if (\defined('PHP_WINDOWS_VERSION_BUILD')) {
foreach ($env as $key => $value) {
- putenv($key.'='.$value);
+ putenv($key . '=' . $value);
}
$env = null;
}
@@ -129,7 +127,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$output->writeln(sprintf('Starting worker %s', $process->getCommandLine()));
if ($input->getOption('foreground')) {
- $process->run(function ($type, $buffer) use ($output) {
+ $process->run(function($type, $buffer) use ($output) {
$output->write($buffer);
});
} // else we recompose and display the worker id
@@ -145,6 +143,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
file_put_contents($pidFile, $pid);
}
- return 0;
+ return Command::SUCCESS;
}
}
diff --git a/Command/StartWorkerCommand.php b/Command/StartWorkerCommand.php
index 26a1c55..242e5d2 100644
--- a/Command/StartWorkerCommand.php
+++ b/Command/StartWorkerCommand.php
@@ -8,6 +8,7 @@
namespace ResqueBundle\Resque\Command;
+use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
@@ -16,24 +17,21 @@
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Process\Process;
-/**
- * Class StartWorkerCommand.
- */
+#[AsCommand(
+ name: 'resque:worker-start',
+ description: 'Start a resque worker',
+)]
class StartWorkerCommand extends Command
{
- private $params;
-
- public function __construct(string $name = null, ParameterBagInterface $params)
+ public function __construct(
+ private ParameterBagInterface $params)
{
- $this->params = $params;
- parent::__construct($name);
+ parent::__construct();
}
protected function configure()
{
$this
- ->setName('resque:worker-start')
- ->setDescription('Start a resque worker')
->addArgument('queues', InputArgument::REQUIRED, 'Queue names (separate using comma)')
->addOption('count', 'c', InputOption::VALUE_REQUIRED, 'How many workers to fork', 1)
->addOption('interval', 'i', InputOption::VALUE_REQUIRED, 'How often to check for new jobs across the queues', 5)
@@ -64,15 +62,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
);
}
- $env['APP_INCLUDE'] = $this->params->get('resque.app_include');
+ $env['APP_INCLUDE'] = $this->params->get('resque.app_include');
$env['COUNT'] = $input->getOption('count');
$env['INTERVAL'] = $input->getOption('interval');
$env['QUEUE'] = $input->getArgument('queues');
// Allow Sentry.io integration
if ($this->params->has('sentry.dsn')) {
- if ($sentryDSN = $this->params->get('sentry.dsn')) {
- $output->writeln('Enabling Sentry Reporting to DSN '.$sentryDSN);
+ if ($sentryDSN = $this->params->get('sentry.dsn')) {
+ $output->writeln('Enabling Sentry Reporting to DSN ' . $sentryDSN);
$env['SENTRY_DSN'] = $sentryDSN;
}
}
@@ -81,9 +79,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
$env['APP_INCLUDE'] = getenv('APP_INCLUDE');
}
- $prefix = $this->params->get('resque.prefix');
+ $prefix = $this->params->get('resque.prefix');
if (!empty($prefix)) {
- $env['PREFIX'] = $this->params->get('resque.prefix');
+ $env['PREFIX'] = $this->params->get('resque.prefix');
}
if ($input->getOption('verbose')) {
@@ -94,27 +92,32 @@ protected function execute(InputInterface $input, OutputInterface $output)
unset($env['VERBOSE']);
}
- $redisHost = $this->params->get('resque.redis.host');
- $redisPort = $this->params->get('resque.redis.port');
- $redisDatabase = $this->params->get('resque.redis.database');
+ $redisHost = $this->params->get('resque.redis.host');
+ $redisPort = $this->params->get('resque.redis.port');
+ $redisDatabase = $this->params->get('resque.redis.database');
+ $redisPassword = $this->params->get('resque.redis.password');
if (null != $redisHost && null != $redisPort) {
- $env['REDIS_BACKEND'] = $redisHost.':'.$redisPort;
+ $env['REDIS_BACKEND'] = $redisHost . ':' . $redisPort;
}
if (isset($redisDatabase)) {
$env['REDIS_BACKEND_DB'] = $redisDatabase;
}
+ if (isset($redisPassword)) {
+ $env['REDIS_BACKEND_PASSWORD'] = $redisPassword;
+ }
+
$opt = '';
- if (0 !== $m = (int) $input->getOption('memory-limit')) {
+ if (0 !== $m = (int)$input->getOption('memory-limit')) {
$opt = sprintf('-d memory_limit=%dM', $m);
}
if (version_compare(PHP_VERSION, '5.4.0') >= 0) {
$phpExecutable = PHP_BINARY;
} else {
- $phpExecutable = PHP_BINDIR.'/php';
+ $phpExecutable = PHP_BINDIR . '/php';
if (\defined('PHP_WINDOWS_VERSION_BUILD')) {
$phpExecutable = 'php';
}
@@ -123,7 +126,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$workerCommand = strtr('%php% %opt% %dir%/resque', [
'%php%' => $phpExecutable,
'%opt%' => $opt,
- '%dir%' => __DIR__.'/../bin',
+ '%dir%' => __DIR__ . '/../bin',
]);
if (!$input->getOption('foreground')) {
@@ -138,7 +141,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
// this is a workaround where we add the vars to the existing environment.
if (\defined('PHP_WINDOWS_VERSION_BUILD')) {
foreach ($env as $key => $value) {
- putenv($key.'='.$value);
+ putenv($key . '=' . $value);
}
$env = null;
}
@@ -151,7 +154,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
// if foreground, we redirect output
if ($input->getOption('foreground')) {
- $process->run(function ($type, $buffer) use ($output) {
+ $process->run(function($type, $buffer) use ($output) {
$output->write($buffer);
});
} // else we recompose and display the worker id
@@ -170,6 +173,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
}
- return 0;
+ return Command::SUCCESS;
}
}
diff --git a/Command/StopScheduledWorkerCommand.php b/Command/StopScheduledWorkerCommand.php
index 1b9eb0b..cf63e3d 100644
--- a/Command/StopScheduledWorkerCommand.php
+++ b/Command/StopScheduledWorkerCommand.php
@@ -8,29 +8,22 @@
namespace ResqueBundle\Resque\Command;
+use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
-/**
- * Class StopScheduledWorkerCommand.
- */
+#[AsCommand(
+ name: 'resque:scheduledworker-stop',
+ description: 'Stop a resque scheduled worker',
+)]
class StopScheduledWorkerCommand extends Command
{
- private $params;
-
- public function __construct(string $name = null, ParameterBagInterface $params)
- {
- $this->params = $params;
- parent::__construct($name);
- }
-
- protected function configure()
+ public function __construct(
+ private ParameterBagInterface $params)
{
- $this
- ->setName('resque:scheduledworker-stop')
- ->setDescription('Stop a resque scheduled worker');
+ parent::__construct();
}
/**
@@ -41,22 +34,22 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
- $pidFile = $this->params->get('kernel.cache_dir').'/resque_scheduledworker.pid';
+ $pidFile = $this->params->get('kernel.cache_dir') . '/resque_scheduledworker.pid';
if (!file_exists($pidFile)) {
$output->writeln('No PID file found');
- return 1;
+ return Command::FAILURE;
}
$pid = file_get_contents($pidFile);
- $output->writeln('Killing process '.$pid);
+ $output->writeln('Killing process ' . $pid);
posix_kill($pid, SIGKILL);
unlink($pidFile);
- return 0;
+ return Command::SUCCESS;
}
}
diff --git a/Command/StopWorkerCommand.php b/Command/StopWorkerCommand.php
index 37422e3..c7eb2e8 100644
--- a/Command/StopWorkerCommand.php
+++ b/Command/StopWorkerCommand.php
@@ -8,6 +8,7 @@
namespace ResqueBundle\Resque\Command;
+use Symfony\Component\Console\Attribute\AsCommand;
use ResqueBundle\Resque\Resque;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
@@ -15,24 +16,21 @@
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
-/**
- * Class StopWorkerCommand.
- */
+#[AsCommand(
+ name: 'resque:worker-stop',
+ description: 'Stop a resque worker',
+)]
class StopWorkerCommand extends Command
{
- private $resque;
-
- public function __construct(string $name = null, Resque $resque)
+ public function __construct(
+ private Resque $resque)
{
- $this->resque = $resque;
- parent::__construct($name);
+ parent::__construct();
}
protected function configure()
{
$this
- ->setName('resque:worker-stop')
- ->setDescription('Stop a resque worker')
->addArgument('id', InputArgument::OPTIONAL, 'Worker id')
->addOption('all', 'a', InputOption::VALUE_NONE, 'Should kill all workers');
}
@@ -62,7 +60,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$output->writeln('There are no running workers.');
}
- return 1;
+ return Command::FAILURE;
}
$workers = [$worker];
@@ -71,7 +69,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
if (!\count($workers)) {
$output->writeln('There are no running workers to stop.');
- return 0;
+ return Command::SUCCESS;
}
foreach ($workers as $worker) {
@@ -84,6 +82,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
}
- return 0;
+ return Command::SUCCESS;
}
}
diff --git a/ContainerAwareJob.php b/ContainerAwareJob.php
index beda44b..8bb6075 100644
--- a/ContainerAwareJob.php
+++ b/ContainerAwareJob.php
@@ -56,7 +56,7 @@ protected function getContainer()
protected function createKernel()
{
$finder = new Finder();
- $finder->name('*Kernel.php')->depth('<=1')->in($this->args['kernel.project_dir'].'/src');
+ $finder->name('*Kernel.php')->depth('<=1')->in($this->args['kernel.project_dir'] . '/src');
$results = iterator_to_array($finder);
$file = current($results);
$class = $file->getBasename('.php');
@@ -64,8 +64,8 @@ protected function createKernel()
// Take into account any namespace
preg_match('/namespace\s(.*)\;/', file_get_contents($file), $matches);
if (2 == \count($matches)) {
- $namespace = '\\'.$matches[1].'\\';
- $class = $namespace.$class;
+ $namespace = '\\' . $matches[1] . '\\';
+ $class = $namespace . $class;
}
require_once $file;
diff --git a/Controller/DefaultController.php b/Controller/DefaultController.php
index 8ca2dab..d731c8b 100644
--- a/Controller/DefaultController.php
+++ b/Controller/DefaultController.php
@@ -76,7 +76,7 @@ public function removeQueueAction($queue, Request $request)
$count = $queue->clear();
$queue->remove();
- $this->addFlash('info', 'Remove '.$queue->getName().' queue and '.$count.' jobs.');
+ $this->addFlash('info', 'Remove ' . $queue->getName() . ' queue and ' . $count . ' jobs.');
return $this->redirectToRoute('ResqueBundle_homepage');
}
@@ -183,7 +183,7 @@ public function retryFailedAction()
{
$count = $this->resque->retryFailedJobs();
- $this->addFlash('info', 'Retry '.$count.' failed jobs.');
+ $this->addFlash('info', 'Retry ' . $count . ' failed jobs.');
return $this->redirectToRoute('ResqueBundle_homepage');
}
@@ -195,7 +195,7 @@ public function retryClearFailedAction()
{
$count = $this->resque->retryFailedJobs(true);
- $this->addFlash('info', 'Retry and clear '.$count.' failed jobs.');
+ $this->addFlash('info', 'Retry and clear ' . $count . ' failed jobs.');
return $this->redirectToRoute('ResqueBundle_homepage');
}
@@ -207,7 +207,7 @@ public function clearFailedAction()
{
$count = $this->resque->clearFailedJobs();
- $this->addFlash('info', 'Clear '.$count.' failed jobs.');
+ $this->addFlash('info', 'Clear ' . $count . ' failed jobs.');
return $this->redirectToRoute('ResqueBundle_homepage');
}
diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php
index 5c911a4..96559d0 100644
--- a/DependencyInjection/Configuration.php
+++ b/DependencyInjection/Configuration.php
@@ -27,7 +27,7 @@ public function getConfigTreeBuilder()
if (method_exists($treeBuilder, 'getRootNode')) {
// Symfony 4+
- $root = $treeBuilder->getRootNode();
+ $root = $treeBuilder->getRootNode();
} else {
// Symfony 3
$root = $treeBuilder->root('resque');
@@ -56,7 +56,7 @@ public function getConfigTreeBuilder()
->arrayNode('auto_retry')
->beforeNormalization()
->ifArray()
- ->then(function ($var) {
+ ->then(function($var) {
if (\array_key_exists(0, $var)) {
return [$var];
}
diff --git a/DependencyInjection/ResqueExtension.php b/DependencyInjection/ResqueExtension.php
index 5ebee20..73948f2 100644
--- a/DependencyInjection/ResqueExtension.php
+++ b/DependencyInjection/ResqueExtension.php
@@ -28,7 +28,7 @@ public function load(array $configs, ContainerBuilder $container)
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
- $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
+ $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.xml');
$container->setParameter('resque.vendor_dir', $config['vendor_dir']);
diff --git a/Queue.php b/Queue.php
index 797c469..563362b 100644
--- a/Queue.php
+++ b/Queue.php
@@ -47,7 +47,7 @@ public function getName()
*/
public function getJobs($start = 0, $stop = -1)
{
- $jobs = \Resque::redis()->lrange('queue:'.$this->name, $start, $stop);
+ $jobs = \Resque::redis()->lrange('queue:' . $this->name, $start, $stop);
$result = [];
foreach ($jobs as $job) {
@@ -68,8 +68,8 @@ public function remove()
*/
public function clear()
{
- $length = \Resque::redis()->llen('queue:'.$this->name);
- \Resque::redis()->del('queue:'.$this->name);
+ $length = \Resque::redis()->llen('queue:' . $this->name);
+ \Resque::redis()->del('queue:' . $this->name);
return $length;
}
diff --git a/README.markdown b/README.markdown
index 1ee8993..44e9fb7 100644
--- a/README.markdown
+++ b/README.markdown
@@ -1,27 +1,32 @@
-[](https://travis-ci.org/resquebundle/resque)
[](https://scrutinizer-ci.com/g/resquebundle/resque/?branch=master)
-**This project IS under ACTIVE development (last major update May 2020)**
+**This project IS NO LONGER UNDER ANY development (last major update September 2021)**
+
+If you would like to take over maintenance of this project please contact phil@phil-taylor.com - I no longer use the code here in any live project as I moved to [Symfony Messenger](https://symfony.com/doc/current/messenger.html), with Redis. for my own queue needs.
+
+# If you are using PHP 8 plesae see the `php8` branch for the latest stable release
+
+
# ResqueBundle
## Compatibiltiy
- - For Symfony 5+ please use ResqueBundle v4.0.0+
- - For Symfony 4+ please use major series ResqueBundle v3+ and work towards Symfony 5 migration ;-)
- - For Symfony 3+ please peg to exact release ResqueBundle v2.0.9+ and think about your decision to even use Symfony 3 ;-)
+- For Symfony 5+ please use ResqueBundle v4.0.0+
+- For Symfony 4+ please use major series ResqueBundle v3+ and work towards Symfony 5 migration ;-)
+- For Symfony 3+ please peg to exact release ResqueBundle v2.0.9+ and think about your decision to even use Symfony 3 ;-)
Note that we dont offer the same b/c promise as symfony itself, but try our hardest to make major versions for major symfony versions.
## Update May 2020
- - Inject ParameterBagInterface instead of directly accessing container in commands and controller
- - User kernel.project_dir instead of kernel.root_dir (b/c break!, you need to update your config yml)
- - Update Routing controller to use long syntax
- - Use `@Bundle` syntax for loading twig templates
- - force a minimum of Symfony 4.1.2 for critical security
- - Use correct Process function for max compatibility
- - Drop Symfony 3.4 support totally, sorry.
+- Inject ParameterBagInterface instead of directly accessing container in commands and controller
+- User kernel.project_dir instead of kernel.root_dir (b/c break!, you need to update your config yml)
+- Update Routing controller to use long syntax
+- Use `@Bundle` syntax for loading twig templates
+- force a minimum of Symfony 4.1.2 for critical security
+- Use correct Process function for max compatibility
+- Drop Symfony 3.4 support totally, sorry.
## Update November 2019
@@ -31,23 +36,23 @@ If you are still using Symfony 3 then you MUST peg your composer.json to release
The first version of this bundle that is highly compatible with, and activly maintained, is 3.0.0
-If you have used this before, and want to get up to date, then you need to
- - upgrade to 3.0.0+ version of this bundle
- - use Symfony 4 (im using 4.4.0RC1 at the moment)
- - change your Jobs to extend `ResqueBundle\Resque\Job` and not `ContainerAwareJob`
- - add `__construct` methods to inject your depenancies
- - remove ALL REFERENCES to the container or `getContainer` from your jobs
- - Enjoy!
+If you have used this before, and want to get up to date, then you need to
+- upgrade to 3.0.0+ version of this bundle
+- use Symfony 4 (im using 4.4.0RC1 at the moment)
+- change your Jobs to extend `ResqueBundle\Resque\Job` and not `ContainerAwareJob`
+- add `__construct` methods to inject your depenancies
+- remove ALL REFERENCES to the container or `getContainer` from your jobs
+- Enjoy!
# ResqueBundle History
-This is a fork of the BCCResqueBundle as ***that** bundle is no longer being actively maintained. There are a lot of outstanding issues, pull requests and bugs that need to be fixed in that project, with no activity, so we forked it, and will activly support and develop the code further in this repo.
+This is a fork of the BCCResqueBundle as ***that** bundle is no longer being actively maintained. There are a lot of outstanding issues, pull requests and bugs that need to be fixed in that project, with no activity, so we forked it, and will activly support and develop the code further in this repo.
This is also a rebrand of Mpclarkson\ResqueBundle to place the code under a GitHub Organisation for future proof distributed development
**Contributions are welcome**
-The resque bundle provides integration of [php-resque](https://github.com/chrisboulton/php-resque/) to Symfony4.
+The resque bundle provides integration of [php-resque](https://github.com/chrisboulton/php-resque/) to Symfony4.
It is inspired from resque, a Redis-backed Ruby library for creating background jobs, placing them on multiple queues, and processing them later.
## Features:
diff --git a/Resque.php b/Resque.php
index f0ba721..b1913bc 100644
--- a/Resque.php
+++ b/Resque.php
@@ -92,7 +92,7 @@ public function setRedisConfiguration($host, $port, $database, $password = null)
];
if (!isset($password)) {
- \Resque::setBackend($host.':'.$port, $database);
+ \Resque::setBackend($host . ':' . $port, $database);
} else {
$server = 'redis://:' . $password . '@' . $host . ':' . $port;
\Resque::setBackend($server, $database);
@@ -263,7 +263,7 @@ public function removeFromTimestamp($at, Job $job)
*/
public function getQueues()
{
- return array_map(function ($queue) {
+ return array_map(function($queue) {
return new Queue($queue);
}, \Resque::queues());
}
@@ -283,7 +283,7 @@ public function getQueue($queue)
*/
public function getWorkers()
{
- return array_map(function ($worker) {
+ return array_map(function($worker) {
return new Worker($worker);
}, \Resque_Worker::all());
}
@@ -293,7 +293,7 @@ public function getWorkers()
*/
public function getRunningWorkers()
{
- return array_filter($this->getWorkers(), function (Worker $worker) {
+ return array_filter($this->getWorkers(), function(Worker $worker) {
return null !== $worker->getCurrentJob();
});
}
@@ -370,7 +370,7 @@ public function getDelayedJobTimestamps()
//TODO: find a more efficient way to do this
$out = [];
foreach ($timestamps as $timestamp) {
- $out[] = [$timestamp, \Resque::redis()->llen('delayed:'.$timestamp)];
+ $out[] = [$timestamp, \Resque::redis()->llen('delayed:' . $timestamp)];
}
return $out;
@@ -391,7 +391,7 @@ public function getNumberOfDelayedJobs()
*/
public function getJobsForTimestamp($timestamp)
{
- $jobs = \Resque::redis()->lrange('delayed:'.$timestamp, 0, -1);
+ $jobs = \Resque::redis()->lrange('delayed:' . $timestamp, 0, -1);
$out = [];
foreach ($jobs as $job) {
$out[] = json_decode($job, true);
diff --git a/Worker.php b/Worker.php
index 98e818e..3ca38d0 100644
--- a/Worker.php
+++ b/Worker.php
@@ -43,7 +43,7 @@ public function stop()
*/
public function getId()
{
- return (string) $this->worker;
+ return (string)$this->worker;
}
/**
@@ -51,7 +51,7 @@ public function getId()
*/
public function getQueues()
{
- return array_map(function ($queue) {
+ return array_map(function($queue) {
return new Queue($queue);
}, $this->worker->queues());
}
diff --git a/bin/resque b/bin/resque
index 15b3fd6..d296228 100755
--- a/bin/resque
+++ b/bin/resque
@@ -106,7 +106,7 @@ if (!empty($PREFIX)) {
}
// If set, re-attach failed jobs based on retry_strategy
-Resque_Event::listen('onFailure', function (Exception $exception, Resque_Job $job) use ($logger, $sentryClient) {
+Resque_Event::listen('onFailure', function (Error | Exception $exception, Resque_Job $job) use ($logger, $sentryClient) {
// Allow integration with Sentry.io
if (null !== $sentryClient){
diff --git a/composer.json b/composer.json
index 46e8f47..503f979 100644
--- a/composer.json
+++ b/composer.json
@@ -1,13 +1,13 @@
{
"name": "resquebundle/resque",
"type": "symfony-bundle",
- "description": "A Symfony 4 bundle to manage Resque job queues",
+ "description": "A Symfony 5 bundle to manage Resque job queues",
"keywords": [
"resque",
"job queue",
"queue",
"symfony",
- "symfony4",
+ "symfony5",
"redis"
],
"homepage": "https://github.com/resquebundle/resque/",
@@ -30,10 +30,10 @@
}
],
"require": {
- "php": ">=7.1",
- "symfony/framework-bundle": "^4.1.2 || ^5.0",
- "symfony/console": "^4.1.2 || ^5.0",
- "symfony/process": "^4.1.2 || ^5.0",
+ "php": ">=8",
+ "symfony/framework-bundle": "^5.3",
+ "symfony/console": "^5.3",
+ "symfony/process": "^5.3",
"resque/php-resque": "^1.3"
},
"require-dev": {