Toby Zerner
Toby Zerner
The Builder pattern is not too far off though, is it? > ... the builder pattern uses another object, a builder, that receives each initialization parameter step by step and...
:P I think I like `json-api-response` anyway, doesn't get much clearer than that Will await @franzliedke's opinion
@franzliedke You might be right, but I'd argue that parsing requests is very much unrelated to building responses and would be better suited to a separate library. In any case,...
@franzliedke care to share some pseudo-code of your entity definitions? It sounds like you have a much better idea of how this would work than I do, I need to...
@franzliedke ah I see, thanks! Hmm, what's the nicest way to replicate a declaration interface like that in PHP, especially where entities must reference each other (`includable has_one('tag', TagResource)`)?
How about something like this? ```php // defining entities use Tobscure\JsonApi\Schema; $postsSchema = new Schema('posts'); $tagsSchema = new Schema('tags'); $postsSchema->attribute('text')->aliasFor('content_text'); $postsSchema->hasMany('tags', $tagsSchema); $tagsSchema->attribute('name'); $tagsSchema->hasMany('posts', $postsSchema); ``` ```php // controller for...
@franzliedke ping :D
It probably makes sense to increase the scope even further, and handle the routing as well. Something like: ```php $controller = new Tobscure\JsonApiServer\Controller; $controller->addResourceType(new PostsResourceType($postRepository)); $controller->addResourceType(new UsersResourceType($userRepository)); $response = $controller->handle($request);...
@f3ath nice! have you benchmarked v2?
Yeah I'm by no means an expert but that's what I would do. Benchmark the construction of a relatively generic real-world document.