Download the PHP package symbiote/silverstripe-apiwrapper without Composer
On this page you can find all versions of the php package symbiote/silverstripe-apiwrapper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download symbiote/silverstripe-apiwrapper
More information about symbiote/silverstripe-apiwrapper
Files in symbiote/silverstripe-apiwrapper
Package silverstripe-apiwrapper
Short Description Provides an API wrapper around service style classes
License BSD-3-Clause
Informations about the package silverstripe-apiwrapper
SilverStripe API Wrapper
Wrap your service APIs in a web layer
Composer Install
Requirements
- SilverStripe 4.1+
Documentation
Quick start
Suppose we have a class Symbiote\Watch\WatchService
that we want to expose
to web requests via /api/v1/watch/{methodname}
First, implement webEnabledMethods
, returning an array of methods mapping to
the request types that can trigger them, ie
In config;
Additional Options
The return of webEnabledMethods can provide additional information, such as
match
You can define a regex in the 'match' key which allows you to match parameters from the URL substring that is left after the api and method paths are removed.
Note that you must define regex using named capture groups.
For example
'match' => '(?<parent>\d+)'
and the URL
/api/v1/list/12
will call the 'list' method with the $parent
parameter set to 12.
Note that this must be the full URL match, meaning you should have a capture
group for all parts of the URL. In other words, the 'match' string is wrapped
in "{^" . $match . "$}"
for the regex that actually gets executed.
Token-based authentcation
Add the user token extension for users and then add the token authenticator middleware
- License
- Contributing