REST API Configuration
The Uplinkr API package is configured from the Laravel application that installs it.
That means:
- the relevant
.envfile is the application’s.env - the relevant config file is
config/uplinkr-api.phpinside the Laravel app - the package does not read a separate
.envfile from insidevendor/
How Configuration Works
Section titled “How Configuration Works”scherhak/uplinkr-api ships with a package config file that is merged into the Laravel application’s configuration.
The defaults come from the package itself, but in normal usage you configure the API through the host application:
.envconfig/uplinkr-api.phpThis is standard Laravel package behavior.
If you change environment values, clear Laravel’s config cache afterwards:
php artisan optimize:clearPublish the Config File
Section titled “Publish the Config File”If you want to customize the API configuration explicitly, publish the package config into your Laravel app:
php artisan vendor:publish --tag=uplinkr-api-configThis creates:
config/uplinkr-api.phpAfter publishing, you can adjust the values there or keep using .env variables referenced by that file.
Important Clarification
Section titled “Important Clarification”If you add values to a .env file inside the package or under vendor/scherhak/uplinkr-api, Laravel will not use them for your application runtime.
Use the Laravel application’s root .env instead.
Correct location:
/your-laravel-app/.envNot used at runtime:
/your-laravel-app/vendor/scherhak/uplinkr-api/.envCommon .env Settings
Section titled “Common .env Settings”The package reads the following environment variables from the Laravel app:
UPLINKR_API_ROUTE_PREFIX=api/v1
UPLINKR_API_AUTH_ENABLED=trueUPLINKR_API_AUTH_HEADER=X-Uplinkr-Api-KeyUPLINKR_API_KEYS=replace-me-with-a-long-random-keyUPLINKR_API_ACCEPT_BEARER_TOKEN=false
UPLINKR_API_RATE_LIMIT_ENABLED=trueUPLINKR_API_RATE_LIMIT_KEY=uplinkr-apiUPLINKR_API_RATE_LIMIT_MAX_ATTEMPTS=60UPLINKR_API_RATE_LIMIT_DECAY_MINUTES=1UPLINKR_API_RATE_LIMIT_BY_IP=trueConfiguration Areas
Section titled “Configuration Areas”Route Prefix
Section titled “Route Prefix”'route' => [ 'prefix' => env('UPLINKR_API_ROUTE_PREFIX', 'api/v1'), 'middleware' => ['api'],],Defines the base URL prefix for all API routes.
Default:
/api/v1API Key Authentication
Section titled “API Key Authentication”'api_key' => [ 'enabled' => (bool) env('UPLINKR_API_AUTH_ENABLED', true), 'header' => env('UPLINKR_API_AUTH_HEADER', 'X-Uplinkr-Api-Key'), 'accept_bearer_token' => (bool) env('UPLINKR_API_ACCEPT_BEARER_TOKEN', true), 'keys' => array_values(array_filter(array_map( static fn (string $value): string => trim($value), explode(',', (string) env('UPLINKR_API_KEYS', '')), ))),],This controls whether the API is protected by keys, which header is used, whether Bearer tokens are accepted, and which keys are valid.
Example:
UPLINKR_API_AUTH_ENABLED=trueUPLINKR_API_AUTH_HEADER=X-Uplinkr-Api-KeyUPLINKR_API_KEYS=key-one,key-twoUPLINKR_API_ACCEPT_BEARER_TOKEN=trueRate Limiting
Section titled “Rate Limiting”'rate_limit' => [ 'enabled' => (bool) env('UPLINKR_API_RATE_LIMIT_ENABLED', true), 'key' => env('UPLINKR_API_RATE_LIMIT_KEY', 'uplinkr-api'), 'max_attempts' => (int) env('UPLINKR_API_RATE_LIMIT_MAX_ATTEMPTS', 60), 'decay_minutes' => (int) env('UPLINKR_API_RATE_LIMIT_DECAY_MINUTES', 1), 'by_ip' => (bool) env('UPLINKR_API_RATE_LIMIT_BY_IP', true),],These settings control the Laravel rate limiter used for the package routes.
Typical Setup In a Laravel App
Section titled “Typical Setup In a Laravel App”- Install the package with Composer.
- Optionally publish the config file.
- Add the required
UPLINKR_API_*values to the Laravel application’s.env. - Clear the config cache.
- Call the API routes from your client or internal tooling.
Example:
composer require scherhak/uplinkr-apiphp artisan vendor:publish --tag=uplinkr-api-configphp artisan optimize:clearExample Host App Configuration
Section titled “Example Host App Configuration”Example .env in the Laravel application:
UPLINKR_API_ROUTE_PREFIX=api/v1UPLINKR_API_AUTH_ENABLED=trueUPLINKR_API_AUTH_HEADER=X-Uplinkr-Api-KeyUPLINKR_API_KEYS=replace-me-with-a-long-random-keyUPLINKR_API_ACCEPT_BEARER_TOKEN=falseUPLINKR_API_RATE_LIMIT_ENABLED=trueUPLINKR_API_RATE_LIMIT_MAX_ATTEMPTS=60UPLINKR_API_RATE_LIMIT_DECAY_MINUTES=1This results in:
- routes under
/api/v1 - API key protection enabled
- the custom header
X-Uplinkr-Api-Key - rate limiting enabled for the REST API
Summary
Section titled “Summary”The package is not configured from its own package directory. It is configured the Laravel way:
- through the host app’s
.env - through the host app’s
config/uplinkr-api.php - with optional config publishing via
vendor:publish