Closed rafatrace closed 8 years ago
Hi, I'm getting this error, maybe someone face this before.
This is my UserSerializer:
class UserSerializer extends AbstractSerializer { protected $type = 'user'; public function getAttributes($item, array $fields = null) { return [ 'id' => $item->id, 'name' => $item->name, 'email' => $item->email ]; } }
And this is the example I'm trying to get to work:
$user = new \stdClass(); $user->id = 24; $user->name = 'Hello World'; $collection = new Collection([$user], new UserSerializer); $document = new Document($collection); echo json_encode($document);
Am I doing something wrong?
I'm unable to reproduce this using your code sample. What version of json-api + PHP are you using?
Sorry for not coming back sooner, I got it working. Structure error
Hi, I'm getting this error, maybe someone face this before.
This is my UserSerializer:
And this is the example I'm trying to get to work:
Am I doing something wrong?