Skip to content

Commit c4415cf

Browse files
committed
Throw an exception when the serializer component is not loaded
1 parent 839dc26 commit c4415cf

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Symfony/Component/Messenger/Transport/Serialization/Serializer.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Messenger\Envelope;
1515
use Symfony\Component\Messenger\Exception\InvalidArgumentException;
16+
use Symfony\Component\Messenger\Exception\RuntimeException;
1617
use Symfony\Component\Serializer\Encoder\JsonEncoder;
1718
use Symfony\Component\Serializer\Encoder\XmlEncoder;
1819
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
@@ -37,6 +38,10 @@ public function __construct(SymfonySerializerInterface $serializer, string $form
3738

3839
public static function create(): self
3940
{
41+
if (!class_exists(SymfonySerializer::class)) {
42+
throw new RuntimeException(sprintf('The default Messenger Serializer requires Symfony\'s Serializer component. Try running "composer require symfony/serializer".'));
43+
}
44+
4045
$encoders = array(new XmlEncoder(), new JsonEncoder());
4146
$normalizers = array(new ObjectNormalizer());
4247
$serializer = new SymfonySerializer($normalizers, $encoders);

0 commit comments

Comments
 (0)