Skip to content

Symfony 6 and PHP 8.1+ #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 23 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
ba36cfd
chore(composer): Update composer.json
MasterRO94 Jan 5, 2023
d6d6947
chore(composer): Update composer.json
MasterRO94 Jan 5, 2023
419bb19
chore(composer): Remove guzzle6 adapter
MasterRO94 Jan 6, 2023
216a5e9
chore(upgrade): Upgrade to work with Symfony 6 and PHP 8.1+
MasterRO94 Mar 15, 2023
569f697
Merge branch 'printedcom:develop' into develop
MasterRO94 Mar 15, 2023
4901d08
sync(fork): Synk fork with original repo
MasterRO94 Mar 15, 2023
043d315
chore(docs): Update changelog and readme
MasterRO94 Mar 15, 2023
8084c96
chore(docs): Update changelog
MasterRO94 Mar 15, 2023
002526e
refactor: Update constructors to use promotion, add type hints and re…
MasterRO94 Mar 16, 2023
d897e84
refactor: Replace switch with match
MasterRO94 Mar 16, 2023
d9214df
refactor: Fix code style
MasterRO94 Mar 16, 2023
f31281e
refactor: Add missing trailing commas. Remove redundant doc blocks. F…
MasterRO94 Mar 16, 2023
50c7e9e
chore(styling): Remove spaces
MasterRO94 Mar 17, 2023
389ff55
chore(phpdocs): Remove redundant @var
MasterRO94 Mar 17, 2023
4631fe7
chore(phpdocs): Remove redundant doc blocks
MasterRO94 Mar 17, 2023
e155742
chore(phpdocs): Reflow long doc line
MasterRO94 Mar 17, 2023
1341dae
fix(command): Treat "The database doesn't exist" and "Couldn't find t…
MasterRO94 Mar 30, 2023
739385f
resolve(): Sync fork with head
MasterRO94 Jun 24, 2025
4a81ca7
Merge pull request #2 from MasterRO94/printedcom-develop
MasterRO94 Jun 24, 2025
3f62e4d
feat: Replace annotations with attributes
MasterRO94 Jun 24, 2025
8bd8c84
Merge pull request #3 from MasterRO94/doctrine/attributes
MasterRO94 Jun 24, 2025
f5f5181
doc: Update CHANGELOG.md
MasterRO94 Jun 24, 2025
cd9fffa
resolve: Sync with develop and resolve conflicts
MasterRO94 Jun 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## [6.1.0] - 2025-06-24
### Changed
- Replaced entity doctrine annotations with php attributes

### Breaking change
- Sync with https://github.com/printedcom/rabbitmq-queue-bundle.git.

## [5.3.2] - 2025-04-02
### Fixed
- Force uuid generation as string when dispatching a QueueTask.
Expand All @@ -26,6 +33,14 @@ Please take care when updating to this version as the index could take a while t
may break the usages only if the call-sites uses php strict types and they were casting this argument to "(string)".
The explicit cast should be removed to resolve this breaking change.

## [6.0.0] - 2023-03-15
### Changed
- Updated dependencies and update code to work with Symfony ^6.0 and PHP ^8.1.

### Breaking changes
- PHP >= 8.1
- Symfony ^6.0

## [5.1.0] - 2023-03-14
### Fixed
- Fix supplying dedicated entity manager to the abstract queue consumer not actually working due to the QueueTask
Expand Down Expand Up @@ -200,6 +215,8 @@ exceptions.
- [Breaking change] Use exchange-less way of using producers and consumers

[Unreleased]: https://github.com/printedcom/rabbitmq-queue-bundle/compare/5.3.1...HEAD
[6.1.0]: https://github.com/MasterRO94/printed-rabbitmq-queue-bundle/compare/6.0.0...6.1.0
[6.0.0]: https://github.com/printedcom/rabbitmq-queue-bundle/compare/5.1.0...MasterRO94:printed-rabbitmq-queue-bundle:6.0.0
[5.3.0]: https://github.com/printedcom/rabbitmq-queue-bundle/compare/5.3.0...5.3.1
[5.3.0]: https://github.com/printedcom/rabbitmq-queue-bundle/compare/5.2.0...5.3.0
[5.2.0]: https://github.com/printedcom/rabbitmq-queue-bundle/compare/5.1.0...5.2.0
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ The bundle piggybacks off of the `php-amqplib/rabbitmq-bundle` bundle.

## Setup & Dependencies

* PHP `>=7.0`
* https://packagist.org/packages/symfony/symfony `^3.4|^4.0`
* https://packagist.org/packages/doctrine/orm `~2.5`
* https://packagist.org/packages/monolog/monolog `~1.11`
* https://packagist.org/packages/ramsey/uuid `~3.4`
* https://packagist.org/packages/php-amqplib/rabbitmq-bundle `~1.6`
* PHP `>=8.1`
* https://packagist.org/packages/symfony/symfony `^6.0`
* https://packagist.org/packages/doctrine/orm `~2.14`
* https://packagist.org/packages/monolog/monolog `~2.8`
* https://packagist.org/packages/ramsey/uuid `~4.7`
* https://packagist.org/packages/php-amqplib/rabbitmq-bundle `~2.11`

We assume that you are familiar with the `php-amqplib/rabbitmq-bundle` configuration and setup.

Expand Down
40 changes: 22 additions & 18 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,33 @@
},

"require": {
"php": ">=7.0",
"php": ">=8.1",

"symfony/config": "^3.4 || ^4.0",
"symfony/console": "^3.4 || ^4.0",
"symfony/dependency-injection": "^3.4 || ^4.0",
"symfony/expression-language": "^3.4 || ^4.0",
"symfony/filesystem": "^3.4 || ^4.0",
"symfony/http-foundation": "^3.4 || ^4.0",
"symfony/http-kernel": "^3.4 || ^4.0",
"symfony/validator": "^3.4 || ^4.0",
"symfony/config": "^6.0",
"symfony/console": "^6.0",
"symfony/dependency-injection": "^6.0",
"symfony/expression-language": "^6.0",
"symfony/filesystem": "^6.0",
"symfony/http-foundation": "^6.0",
"symfony/http-kernel": "^6.0",
"symfony/validator": "^6.0",

"doctrine/cache": "^1.6",
"doctrine/doctrine-bundle": "~1.4",
"doctrine/orm": "~2.5",
"doctrine/cache": "^2.0",
"doctrine/doctrine-bundle": "^2.8",
"doctrine/orm": "^2.14",

"monolog/monolog": "~1.11",
"monolog/monolog": "^2.8",

"php-amqplib/rabbitmq-bundle": "^1.13.0",
"php-amqplib/rabbitmq-bundle": "^2.11",

"ramsey/uuid": "~3.4",
"php-http/guzzle6-adapter": "^1.1",
"richardfullmer/rabbitmq-management-api": "^2.0",
"ramsey/uuid": "^4.7",
"php-http/guzzle7-adapter": "^1.0",
"andrewmy/rabbitmq-management-api": "^2.1",
"psr/log": "^1.0"
},
"config": {
"allow-plugins": {
"php-http/discovery": true
}
}

}
15 changes: 7 additions & 8 deletions src/Printed/Bundle/Queue/Command/EnsureVhostExistsCommand.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Printed\Bundle\Queue\Command;

use Printed\Bundle\Queue\Service\RabbitMqVhostExistenceEnsurer;
Expand All @@ -13,21 +15,16 @@
*/
class EnsureVhostExistsCommand extends Command
{
/** @var RabbitMqVhostExistenceEnsurer */
private $rabbitMqVhostExistenceEnsurer;

public function __construct(
RabbitMqVhostExistenceEnsurer $rabbitMqVhostExistenceEnsurer
private readonly RabbitMqVhostExistenceEnsurer $rabbitMqVhostExistenceEnsurer,
) {
parent::__construct();

$this->rabbitMqVhostExistenceEnsurer = $rabbitMqVhostExistenceEnsurer;
}

/**
* {@inheritdoc}
*/
protected function configure()
protected function configure(): void
{
$this->setName('queue:ensure-vhost-exists');
$this->setDescription("Ensures, that a rabbitmq's vhost exists, and that rabbitmq's user can manage it");
Expand All @@ -36,13 +33,15 @@ protected function configure()
/**
* {@inheritdoc}
*/
public function execute(InputInterface $input, OutputInterface $output)
public function execute(InputInterface $input, OutputInterface $output): int
{
if ($output->getVerbosity() === OutputInterface::VERBOSITY_NORMAL) {
$output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE);
}

$this->rabbitMqVhostExistenceEnsurer->ensure();

return static::SUCCESS;
}

}
17 changes: 8 additions & 9 deletions src/Printed/Bundle/Queue/Command/MaintenanceDownCommand.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Printed\Bundle\Queue\Command;

use Printed\Bundle\Queue\Service\QueueMaintenance;
Expand All @@ -12,20 +14,15 @@
*/
class MaintenanceDownCommand extends Command
{
/** @var QueueMaintenance */
private $queueMaintenance;

public function __construct(QueueMaintenance $queueMaintenance)
public function __construct(private readonly QueueMaintenance $queueMaintenance)
{
parent::__construct();

$this->queueMaintenance = $queueMaintenance;
}

/**
* {@inheritdoc}
*/
protected function configure()
protected function configure(): void
{
$this->setName('queue:maintenance:down');
$this->setDescription('Disable the maintenance mode for the queue');
Expand All @@ -35,10 +32,12 @@ protected function configure()
/**
* {@inheritdoc}
*/
public function execute(InputInterface $input, OutputInterface $output)
public function execute(InputInterface $input, OutputInterface $output): int
{
$output->writeln('<info>Disabling maintenance mode</info>');

$this->queueMaintenance->disable();

return static::SUCCESS;
}
}
15 changes: 7 additions & 8 deletions src/Printed/Bundle/Queue/Command/MaintenanceUpCommand.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Printed\Bundle\Queue\Command;

use Printed\Bundle\Queue\Service\QueueMaintenance;
Expand All @@ -12,20 +14,15 @@
*/
class MaintenanceUpCommand extends Command
{
/** @var QueueMaintenance */
private $queueMaintenance;

public function __construct(QueueMaintenance $queueMaintenance)
public function __construct(private readonly QueueMaintenance $queueMaintenance)
{
parent::__construct();

$this->queueMaintenance = $queueMaintenance;
}

/**
* {@inheritdoc}
*/
protected function configure()
protected function configure(): void
{
$this->setName('queue:maintenance:up');
$this->setDescription('Puts the queue in to maintenance mode');
Expand All @@ -35,10 +32,12 @@ protected function configure()
/**
* {@inheritdoc}
*/
public function execute(InputInterface $input, OutputInterface $output)
public function execute(InputInterface $input, OutputInterface $output): int
{
$output->writeln('<info>Enabling maintenance mode</info>');

$this->queueMaintenance->enable();

return static::SUCCESS;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Printed\Bundle\Queue\Command;

use Doctrine\DBAL\Connection;
Expand All @@ -17,26 +19,17 @@
*/
class MaintenanceWaitForRunningCommand extends Command
{
/** @var QueueMaintenance */
private $queueMaintenance;

/** @var Connection */
private $dbalConnection;

public function __construct(
QueueMaintenance $queueMaintenance,
Connection $dbalConnection
private readonly QueueMaintenance $queueMaintenance,
private readonly Connection $dbalConnection,
) {
parent::__construct();

$this->queueMaintenance = $queueMaintenance;
$this->dbalConnection = $dbalConnection;
}

/**
* {@inheritdoc}
*/
protected function configure()
protected function configure(): void
{
$this->setName('queue:maintenance:wait');
$this->setDescription('Wait for running tasks to complete and exit');
Expand All @@ -49,7 +42,7 @@ protected function configure()
/**
* {@inheritdoc}
*/
public function execute(InputInterface $input, OutputInterface $output)
public function execute(InputInterface $input, OutputInterface $output): int
{
$output->writeln('<info>Monitoring running tasks</info>');

Expand All @@ -65,28 +58,30 @@ public function execute(InputInterface $input, OutputInterface $output)
$dbal = $this->dbalConnection;

if (!$this->doesDatabaseExist($dbal)) {
$output->writeln("<error>The database doesn't exist. This is expected, if the bundle is used for the first time. Otherwise it's a critical error you should investigate.</error>");
return;
$output->writeln("<comment>The database doesn't exist. This is expected, if the bundle is used for the first time. Otherwise, it's a critical error you should investigate.</comment>");

return static::SUCCESS;
}

/*
* Exit immediately if the queue tasks db table is not in the database. Assume no workers
* are running.
*/
if (!in_array('queue_task', $dbal->getSchemaManager()->listTableNames())) {
$output->writeln("<error>Couldn't find the queue tasks table in the database. This is expected, if the bundle is used for the first time. Otherwise it's a critical error you should investigate.</error>");
return;
if (!in_array('queue_task', $dbal->createSchemaManager()->listTableNames())) {
$output->writeln("<comment>Couldn't find the queue tasks table in the database. This is expected, if the bundle is used for the first time. Otherwise, it's a critical error you should investigate.</comment>");

return static::SUCCESS;
}

// Get the refresh time, this is 3 by default.
$refresh = (integer) $input->getOption('refresh');
$refresh = (int) $input->getOption('refresh');

$table = new Table($output);
$table->setHeaders(['Queue', 'Tasks']);

while (true) {
// Find all tasks with running status.
$tasks = $dbal->fetchAll(
$tasks = $dbal->fetchAllAssociative(
'SELECT id, queue_name FROM queue_task WHERE status = :status_running',
[ 'status_running' => QueueTaskStatus::RUNNING ]
);
Expand All @@ -95,7 +90,8 @@ public function execute(InputInterface $input, OutputInterface $output)
// If there are none we can exit the command.
if ($count === 0) {
$output->writeln(sprintf('<info>There are no tasks in running state!</info>'));
return;

return static::SUCCESS;
}

$table->setRows([]);
Expand Down Expand Up @@ -162,7 +158,7 @@ private function doesDatabaseExist(Connection $connection): bool

$tmpConnection = DriverManager::getConnection($params);

$doesDatabaseExist = in_array($name, $tmpConnection->getSchemaManager()->listDatabases());
$doesDatabaseExist = in_array($name, $tmpConnection->createSchemaManager()->listDatabases());

$tmpConnection->close();

Expand Down
Loading