I've got in my symfony2 project, a custom entity outside Bundles and framework.
I need set json data into this entity, but i can't apply right configuration to user yaml file.
app/config/config.yml
jms_serializer:
metadata:
auto_detection: true
directories:
CORE:
namespace_prefix: "Core\Domain\Model"
path: "%kernel.root_dir%/Resources/serializer/CORE"
app/Resources/serializer/CORE/Model.Product.yml
Core\Domain\Model\Product\Product:
properties:
id:
type: integer
objectId:
type: string
name:
type: string ...
It's possible that this bundle dont works fine with entities outside bundles?.
Always I see error message: You must define a type for Core\Domain\Model\Product\Product::$id.
I think that JMSSerializerBundle don't read yaml file, because with annotations works fine.
Any idea?.
Thanks.
In your
app/config/config.yml
be sure to use\\
as namespace separator instead of\
:Otherwise the backslashes are treated as escape characters for the following letters.
Edit: Also make sure to name the JMS serializer config properly. For the class
Core\Domain\Model\Product\Product
you need aProduct.Product.yml
file inside the specifiedpath
of the config. In your example, your file is namedModel.Product.yml
.So to get the serializer config file name for an entitiy in general:
namespace
defined in the config from the class name\
with.
.yml
and put the file in thepath
folder defined in the config