From 09f09e7ba9ffee4204866ca4c0f5abaedeb8d189 Mon Sep 17 00:00:00 2001 From: Andreas Erhard Date: Wed, 7 Oct 2020 19:16:35 +0200 Subject: [PATCH] Reduce dependency coupling for symfony/process Move symfony/process to an optional dependency (required for dev, suggested otherwise). This is a preparation for #78. --- composer.json | 9 +++++---- src/Resque/Commands/SpeedTest.php | 6 ++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 24c6464..e819a7b 100644 --- a/composer.json +++ b/composer.json @@ -17,16 +17,17 @@ "predis/predis": "1.1.*", "monolog/monolog": "~1.7", "symfony/console": "~2.7|~3.0", - "symfony/yaml": "~2.7|~3.0", - "symfony/process": "~2.7|~3.0" + "symfony/yaml": "~2.7|~3.0" }, "suggest": { "ext-proctitle": "Allows php-resque to rename the title of UNIX processes to show the status of a worker in PHP versions < 5.5.0.", - "ext-phpiredis": "Native PHP extension for Redis connectivity. Predis will automatically utilize when available." + "ext-phpiredis": "Native PHP extension for Redis connectivity. Predis will automatically utilize when available.", + "symfony/process": "To run the speed test command." }, "require-dev": { "phpunit/phpunit": "~4.8", - "friendsofphp/php-cs-fixer": "~2.2.0" + "friendsofphp/php-cs-fixer": "~2.2.0", + "symfony/process": "~2.7|~3.0" }, "bin": [ "bin/resque" diff --git a/src/Resque/Commands/SpeedTest.php b/src/Resque/Commands/SpeedTest.php index 6827b04..059e258 100644 --- a/src/Resque/Commands/SpeedTest.php +++ b/src/Resque/Commands/SpeedTest.php @@ -21,6 +21,8 @@ use Symfony\Component\Process\Process; use Symfony\Component\Console\Helper\ProgressBar; +use Exception; + /** * Performs a raw speed test * @@ -41,6 +43,10 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output) { + if (!class_exists(Process::class)) { + throw new Exception('The Symfony process component is required to run the speed test.'); + } + Resque\Redis::setConfig(array('namespace' => 'resque:speedtest')); $testTime = (int)$input->getOption('time') ?: 5;