-
-
Notifications
You must be signed in to change notification settings - Fork 316
Restler 3: Doc Comments
You may use the following php doc comments to annotate your methods.
- @url
- @access
- @smart-auto-routing
- @class
- @cache
- @expires
- @throttle
- @status
- @header
- @param
- @throws
- @return
All tags except @url can also be defined at the class level.
Overrides auto routes and creates manual routes. use as many as you need ###Syntax: @url GET|POST|PUT|PATCH|DELETE custom/{dynamic}/route ###Example: @url POST authors/{id}/books
Access control for api methods. PHPDoc only supports private and public, Restler adds protected for api that needs authentication, hybrid for api that enhances resulting data for authenticated users.
@access private|public|protected|hybrid
###Example: POST authors/{id}/books
Smart auto routing is enabled by default. Avoids creating multiple routes that can increase the ambiguity when set to true. when a method parameter is optional it is not mapped to the url and should only be used in request body or as query string /resource?id=value
. When a parameter is required and is scalar, it will be mapped as part of the url /resource/{id}
@smart-auto-routing true|false
Example: POST authors/{id}/books
##@class Inject property of the specified class with specified value
@class ClassName {@propertyName value}
###Example: @class AccessControl {@requires user} {@level 5}
##@cache Specify value to set CacheControl Header, it can use @expires value as shown in the example
@cache headerCacheControlValue
###Example: @cache max-age={expires}, must-revalidate
##@expires Sets the content to expire immediately when set to zero alternatively you can specify the number of seconds the content will expire
@expires numberOfSeconds
###Example: @expires 30
##@throttle Sets the time in milliseconds for bandwidth throttling, which will become the minimum response time for each API request.
@throttle numberOfMilliSeconds
###Example: @throttle 3000
##@status Sets the HTTP Status code for the successful response.
@status httpStatusCode
###Example: @status 201
##@header Sets or overrides the specific HTTP Header.
@header httpHeader
###Example: @header Link: <meta.rdf>; rel=meta
##@param Sets the HTTP Status code for the successful response
@param [type] Name [Description] {@name value}
###Example: @param int $num1 increment value {@min 5} {@max 100}
##@throws Documents possible error responses for the API call.
@throws httpStatusCode [Reason]
###Example: @throws 404 No Author for specified id
##@return Documents the structure of success response, user defined classes must extend iValueObject.
@return type [Description]
###Example: return Author an instance of iValueObject