JWT Framework
Search…
JWS serializers

JWS Serializer Manager Factory Service

A JWSSerializerManagerFactory is available as a service in your application container:
1
<?php
2
use Jose\Component\Signature\JWSSerializerManagerFactory;
3
4
$jwsSerializerManagerFactory = $container->get(JWSSerializerManagerFactory::class);
Copied!
With this factory, you will be able to create the JWSSerializerManager you need:
1
$jwsSerializerManager = $jwsSerializerManagerFactory->create(['jws_compact']);
Copied!
You can now use the JWSSerializerManager as explained in the JWS Creation/Loading section.
Available JWS serialization modes are:
    jws_compact
    jws_json_general
    jws_json_flattened

JWS Serializer Manager As Service

There is also another way to create a JWSSerializerManager object: using the bundle configuration.
1
jose:
2
jws:
3
serializers:
4
serializer1:
5
serializers: ['jws_compact']
6
is_public: true
Copied!
With the previous configuration, the bundle will create a public JWS Serializer Manager service named jose.jws_serializer.serializer1 with selected serialization modes.
1
<?php
2
$jwsSerializerManager = $container->get('jose.jws_serializer.serializer1');
Copied!

Custom Tags

You can add custom tags and attributes to the services you create.
1
jose:
2
jws:
3
serializers:
4
serializer1:
5
serializers: ['jws_compact']
6
tags:
7
tag_name1: ~
8
tag_name2: {attribute1: 'foo'}
Copied!
Last modified 1yr ago