232
questions
1
vote
0
answers
54
views
Can you make Doctrine return a fresh instance of an Entity generated from the DB than the one that was inserted?
We are upgrading a web API from:
PHP 7.4
Symfony 4.4
Doctrine 2.8
To:
PHP 8.2
Symfony 5.4
Doctrine 2.19
We have a large main entity, with many Collection objects, containing other entities. We ...
0
votes
0
answers
18
views
JMS Serializer Discriminater by by Root Name
I would like to discriminate by rootNodeName
So that I can handle XML like these:
<A>
<Id>1234</Id>
</A>
<B>
<Id>5678</Id>
</B>
and handle them ...
0
votes
0
answers
21
views
Get deep data using JMS\SerializedName
I have json
"CheckSum":{
"NumberRecordings":"1",
"Total":"1"
}
And have model
final class RegisterModel
{
#[
Assert\NotBlank,
...
0
votes
0
answers
19
views
JMS Serializer unknownObjects
I'm trying to modify a Object of my collection that it can handle unknown objects
I Got Objects A, B, C but it can also happen that I get an Object Z which I have no presentation in My ...
0
votes
0
answers
25
views
How to deserialize into wrapper object (jms serializer)?
I use jms serializer (https://jmsyst.com/libs/serializer) outside symfony framework. I had structure of response like that:
[
{ "id": 1 },
{ "id": 2 }
]
When I use
$...
1
vote
0
answers
44
views
Why JMS Serializer prefixes UPPERCASE properties with an underscore?
Is it normal for JMS Serializer to transform an object property called LDAP (note the capital letters) into _ldap (note the underscore)?
Array before:
Array after serialization:
If this property is ...
0
votes
0
answers
29
views
jms / fos paramconverter - deserialize multiple objects from single payload
i'd like to use the fos / jms bodyconverter in symfony to deserialize two objects from one request payload:
{ "object_data_1": ..., "object_data_2" : ...}
and then capture like so:...
0
votes
0
answers
77
views
JMS Serializer. Can not use context from yaml.file to serialize object with groups
jms/serializer-bundle: 5.4.0 and symfony project 6.4
I have in framework.yaml
...
serializer:
mapping:
paths: ['%kernel.project_dir%/config/serialization']
...
In folder ...
1
vote
1
answer
75
views
Deserializer does only work with additional tag
I want do deserialize an XML-Feed to a list of Objects. Here are my classes
namespace App\Test;
use JMS\Serializer\SerializerInterface;
class Test
{
public function __construct(private readonly ...
0
votes
0
answers
55
views
How to configure JMSSerializerBundle to use UnserializeObjectConstructor instead of DoctrineObjectConstructor
After updating JMSSerializerBundle + JMSSerializer (4.2.0 / 3.22.0 --> 5.3.1 / 3.28.0) in my Symfony 6.3, deserialized object are now automatically added to the Doctrine EntityManager (= become ...
0
votes
1
answer
128
views
JMSSerializer - Custom handler for a property
I know that I can declare a custom handler for a whole type. But what if I want to use different approach for serializing the same type in different situation?
For example I have an entity, it has a ...
0
votes
0
answers
51
views
JMS serialized XmlAttribute with HTML entity &
I use this annotation for property "picture"
@JMS\XmlAttribute()
Build result with methods
\JMS\Serializer\SerializerBuilder::create()->build()->serialize($data, 'xml')
Object with ...
0
votes
1
answer
44
views
JMS Service not pushing XML files to Queue. Stops processing in between and needed to restart the service to push the files further
There is a directory named /var/xyz/aa/clm/data/infiles/SenderJMS/CE/L3/ where number of XML files are stored after a process runs. These files contain data to be pushed to remote server through a JMS ...
1
vote
1
answer
386
views
Equivalance symfony/serializer "SerializedPath" for jms/serializer
I have this particular json to decode with jms/serializer:
{
"id": 42,
"attributes": {
"name": "toto",
"alternativeText": null
}
}
into:...
0
votes
1
answer
475
views
Change Symfony serializer order when extending models
I am working on a REST API with Symfony 5.4; PHP 7.4; using the default Symfony serializer. When I define a model extending from another, the properties of the child model are serialized before the ...
0
votes
1
answer
418
views
JMSSerializer > don't return null value and empty array
I want to serialize some object but don't return null values or empty array.
Here is my json:
{
"success": true,
"detail": {
"id": 588,
"label": null,
...
2
votes
3
answers
2k
views
Automatically implementing JMS serialization for many php backed enums
Context
By using the JMS serializer library, I need to serialize/unserialize data which are internally represented by php backed enums.
What's the problem
I found a solution by using the ...
0
votes
0
answers
153
views
Try to update Sonata, have error with jms-serializer
I need to update my bundles for security reasons but when i try to do a composer update, i have a lot of problem with sonata.
First, SonataCore, sonataMedia and JMS-serializer disappear.
bundles.php
...
1
vote
1
answer
1k
views
Symfony: how to add a serializer group on a Route depending on logged in user's roles
I'm using JMSSerializerBundle in my entities definition, and RestBundle's annotations in controllers.
I have an entity with public and admin-protected attributes, let's say
use JMS\Serializer\...
5
votes
0
answers
2k
views
Symfony serializer Virtual Property like JMS Expression Prop
I'm on a project currently using JMS Serializer in an API.
We use a lot of virtual properties - especially expression Prop in the serialization mapping.
App\Entity\MyEntity:
exclusion_policy: none
...
1
vote
1
answer
885
views
how can I make JMS/Serializer deserialize this property to object?
I have the following class
use JMS\Serializer\Annotation as Serializer;
use JMS\Serializer\Annotation\ExclusionPolicy;
use JMS\Serializer\Annotation\Type;
/**
* @ExclusionPolicy("none")
*/...
0
votes
1
answer
228
views
Using JMS Serializer with PHPSpec testing case causes The annotation @JMS\Serializer\Annotation\Type does not exist, or could not be auto-loaded
I have a function to transform array into object.
public function transform(array $pickupPoints): array
{
return SerializerBuilder::create()
->setSerializationContextFactory(function () ...
1
vote
2
answers
2k
views
Deserialize single string property into object in symfony JMS PHP
Having PHP, Symfony 4.4, JMS Serializer and json payload (request body) as such:
{
"quantity": 1,
"product": {
"sku": "bla"
},
"myId": {
...
0
votes
0
answers
402
views
JMS\Serializer OBJECT_TO_POPULATE
Is it possible deserialize to an object with JMS\Serializer?
I don't see n option like the one Symfony Serializer has:
https://symfony.com/doc/current/components/serializer.html#deserializing-in-an-...
1
vote
1
answer
934
views
Symfony 5 NelmioDocsBundle and JMS Seralizer
Having a bit of trouble understanding the combo of tools in the title.
When I view my docs the model is empty:
That said I've tried a bunch of things including disabling jms which works but I want to ...
0
votes
1
answer
2k
views
How to serialize object as its own property (array) using JMS Serializer EventSubscriberInterface (php, symfony)
I need to serialize an object as its own property (it's type is array), I mean that the object has an array property books, and after transforming it I want to skip the books key, so the structure ...
0
votes
1
answer
175
views
Strange Offset between De- and Serialization of Datetime with JMS Serializer
I'm developing a scheduling app whose frontend communicates with the backend via UNIX-Timestamp-based time fields. The app has been used for almost a year in production, but suddenly, thank god only ...
8
votes
2
answers
5k
views
How to use inherited classes with API-Platform
I wish to use API-Platform to perform CRUD operations on object hierarchy classes. I found little written when using inherited classes with API-Platform and some but not much more when used with ...
0
votes
2
answers
2k
views
Symfony 5.2 Error: The directory "var/cache/dev/jms_serializer" does not exist
Symfony 5.2 with jms/serializer-bundle 3.7.0.
After symfony cache cleaning by command cache:clear on the next request I get an error:
The directory "var/cache/dev/jms_serializer" does not ...
0
votes
2
answers
397
views
Symfony5 JMS Serializer - model with calculated property without ORM annotation
I have model properties like this:
/**
* @ORM\Entity(repositoryClass=AssignmentRepository::class)
*/
class Assignment
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type=&...
1
vote
0
answers
197
views
JMS deserialize part of an xml
I am trying to deserialize a complicated xml, and I only need a nested part of the xml not the whole part.
There is a simple example, what I'd like to do:
<foo>
<bar>
<user>
...
0
votes
1
answer
794
views
Default deserializeFormats for DateTime in JMS Serializer
I see default_format and default_timezone configs for deserializing datetime values but I don't see a config to specify a list of alternate formats. I would like for my API to accept timestamps with ...
0
votes
0
answers
124
views
JMSConnection serialization fail
Currently I'm building an application that reads messages (transactions in json) in a Kafka Topic and sends to IBM MQ at production. I'm having some trouble with serialization in the JMS classes and ...
1
vote
1
answer
839
views
How can I all errors show in json format in friendsofsymfony/rest-bundle v3
I want intercept all errors of Symfony after that show them in JSON.
In friendsofsymfony/rest-bundle v2 I can set parameters
fos_rest:
exception:
enabled: true
...
2
votes
0
answers
31
views
Is it possible to create a group dependency in JMS
Lets say I have following structure:
Article:
name
content
galleries: array of Gallery
Gallery:
name
description
media : array of Media
thumbnail: Media
Media:
name
file
Now when I am ...
0
votes
1
answer
460
views
symfony serializer jmsserializerbundle service name conflict
I have the following issue: I am working on a symfony (2.8) project which depends on the jmsserializerbundle (1.1).
When enabling the symfony-serializer alongside the jms-serializer package,
# app/...
1
vote
1
answer
1k
views
Symfony 3.4 JMS Serializer DoctrineObjectConstructor::__construct() expect ManagerRegistry, instance of Doctrine\Bundle\DoctrineBundle\Registry given
Please help me , I am stuck here. I have recently upgraded Symfony version from 2.8 to Symfony 3.4 LTS version. All works fine except the Rest API end point where I extend the Sonata\UserBundle\...
3
votes
1
answer
1k
views
Symfony + JMS Serializer: Deserializing a DateTime value returns current time also
I have the following annotation for the birthDate field:
/**
* @Serializer\SerializedName("birthDate")
* @Serializer\Type("DateTimeImmutable<'Y-m-d'>")
*/
public $birthDate;
...
0
votes
2
answers
2k
views
How configure JMSSerializer in Symfony to serialize custom class to/from int?
I am working on a Symfony 3.4 based web app project which uses JMSSerializer to serialize different custom classes to JSON to send this data to mobile apps.
How can I serialize/deserialize a custom ...
1
vote
1
answer
143
views
JMSSerializer hasData deprecated
I have an entity with relatives paths. If those links are serialized, I want to change them to an absolute path.
class EntityA
{
/**
* @var string
*
* @Serializer\Expose
* @...
0
votes
1
answer
1k
views
Using a different naming strategy for each class with JMS and Symfony 3.4
Hello dear Stackoverflow community,
I have 2 PHP class (considered as DTO) that I'm using to set the body of my HTTP calls.
Each DTO is used for a different API with different naming strategies (one ...
1
vote
0
answers
177
views
jms serializer @Exclude condition on class
My question is rather equal to Symfony2 - JMS Serializer - Exclude entity if getDeleted() is not null but the accepted answer offered a workaround and not an actual response and does not fit my ...
1
vote
0
answers
234
views
2 identical JMS listeners are implemented instead of the 1st. ActiveMQ And cannot transmit and receive the object
I am writing an application in Spring (I do not use Spring Boot). The application uses the JMS broker ActiveMQ.
Listener:
@Component
public class ReceiveMessage {
private HistoryService ...
2
votes
0
answers
3k
views
How to specify several object type within single property using Swagger and/or JMS serializer?
I use Swagger and JMS serializer and show built OpenAPI JSON using NelmioAPIDocBundle https://github.com/nelmio/NelmioApiDocBundle
I have an object with a property, which is an array, that might ...
0
votes
1
answer
1k
views
JMS Serializer expressions not working in virtual property with Symfony 3.4
I recently deep dived into JMS Serializer and although I like it how the package makes a lot of things convenient for the developer in serialisation/deserialisation but there is a major lack of ...
1
vote
2
answers
971
views
JMS Serializer perfomance issues with more than 10000 entries
Currently I'm building a PHP command that can update my ElasticSearch indices.
But, a big thing I've noticed is that serializing entities when my array holds more than 10000 of them is taking way ...
0
votes
0
answers
322
views
Symfony JMS Serializer - Endpoint for uploaded files
How can I upload a file using JMS Serializer? Now I'm getting Notice: Array to string conversion
App\Entity\Answer
/**
* @Type("string")
* @ORM\Column(type="string", length=255, nullable=true)
*/
...
1
vote
0
answers
402
views
How to serialize an object "datetime" property into a "date" elasticsearch type, not "text"
I am creating a website using Symfony 4.
Visitors will need to search through thousands of articles ordered by "dynamic_date". I use Elasticsearch 6.7, FOSElasticaBundle and JMS Serializer to index "...
0
votes
1
answer
1k
views
Mixing Accessor and SkipWhenEmpty in JMS Serializer
I'm using JMS serializer in a project, and I'm struggling with one thing.
I'm using the @Accessor annotation (On a DateTime property) to echo only the date without the time. But on some of my objects,...
0
votes
1
answer
1k
views
problem with converting a entity to json using jms_serializer - Symfony 4
i'm trying to make an api to return a json with symfony 4
i create a entity and it's work fine but it do not convert data for database to json
so the Serializer from "Symfony\Component\Serializer\...