Skip to content

Instantly share code, notes, and snippets.

@dunglas
Last active December 18, 2020 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dunglas/4da2026f34bf7f18e1db955ef8a9b417 to your computer and use it in GitHub Desktop.
Save dunglas/4da2026f34bf7f18e1db955ef8a9b417 to your computer and use it in GitHub Desktop.
Proposal: new public API for API Platform and the TypeScript library
<?php
// Verbose
#[Get] // path defaults to /users
#[Get("/company/{companyId}/users")]
#[Post] // path defaults to /users
#[Post("/company/{companyId}/users)]
class Users extends \ArrayObject
{
}
#[Get]
#[Get("/company/{companyId}/users/{id})]
#[Put]
// ...
#[Delete]
// ..
class User
{
public $id;
}
// Less verbose
#[Resource(groups: ['foo'])]
#[CGet]
#[CPost]
#[Get]
#[Put]
#[Delete]
#[\Orm\Entity]
class User
{
public $id;
}
// Less less verbose
#[Resource(collection: true/false, item: true/false)]
#[\Orm\Entity]
class User
{
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment