Last active
December 18, 2020 14:20
-
-
Save dunglas/4da2026f34bf7f18e1db955ef8a9b417 to your computer and use it in GitHub Desktop.
Proposal: new public API for API Platform and the TypeScript library
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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