Skip to content

Configuration

Abhinav Saraswat edited this page Nov 24, 2016 · 2 revisions

The package comes with various configurable options. To override the default options, you need to publish the config file using the following command:

php artisan vendor:publish --provider="Froiden\RestAPI\Providers\ApiServiceProvider"

After running this command, a new file api.php will be created in your config directory.

Options

Note: You may not understand some of the the options described below until you read the later chapters of this wiki and start using the package.

defaultLimit (default = 10)

The default number of records to return when the user does not specify the limit parameter. You can set a value that suits your needs. For example, Facebook Graph API returns 25 records by default.

maxLimit (default = 1000)

The maximum number of records a user can request in a single API call. Without this option, the user will be able to request an infinite number of records, in a single call, putting a heavy load on your API. It defaults to 1000.

cors (default = true)

Add cross-origin headers to responses, enabling API calls from any domain. It is recommended by Microsoft REST API Guidelines to allow cross-origin requests. However, you can disable it with this option.

excludes (default = [_token])

The package supports saving and updating of models out of the box. This feature uses all fields from a request and assumes to be model attributes. If you are sending some fields that are not model attributes, specify them in this list.

prefix (default = api)

The prefix to add to API routes. Set it to null for no prefix.

defaultVersion (default = v1)

The package supports API versioning. This parameter defined what version should a route be assigned if no version is defined for it in routes.php. If this is set to null, no API version will be assigned that route.

Clone this wiki locally