Skip to main content

Configuration

Publish the configuration file, where every option is documented inline:

php artisan vendor:publish --tag=frontline-api-config

The package registers one tag per publishable group, plus an umbrella tag that takes all of them. This portal is the canonical list; the README carries the short version.

TagPublishes
frontline-apieverything below, in one command
frontline-api-configthe configuration file
frontline-api-migrationsthe database migrations
frontline-api-langthe translation files

Migrations​

The migrations run from the package as they are, with php artisan migrate. Publishing them, on their own or through the umbrella tag, writes a copy into database/migrations, under a new date with Laravel's default configuration, and the package still registers its own. Call \Pushery\FrontlineApi\FrontlineApiServiceProvider::ignoreMigrations(tablesExist: true) in the register method of one of your service providers before you publish them, or the copy fails on a table that already exists. tablesExist: true keeps the package's schedule, which publishes the sheets and the heartbeat every minute and counts and prunes the meter from these tables; ignoreMigrations() alone declines the tables and takes all of that off the schedule.

On a connection with a table prefix that sets prefix_indexes, as the pgsql connection of Laravel's config/database.php does, the indexes the migrations name carry the prefix on PostgreSQL and SQLite, as the names Laravel derives do, so two installs under different prefixes in one schema build indexes of their own. MySQL allows an index name once per table, and there the names stay as they are.

Make that switch before your first php artisan migrate, and publish the migrations once. The release notes name each migration a later release adds: copy that file from vendor/pushery/frontline-api-for-laravel/database/migrations into database/migrations, renamed to start with today's date so it runs after the copies you have, then run php artisan migrate. Publishing the tag again writes every migration a second time under a new date, and migrate runs each copy as a new migration over the tables the original created.

A copy that finds its table leaves the table as it is, once the table carries every index the migration creates. A table that lacks one stops migrate with a message that names the table, the index and the repair: on MySQL and SQLite, which change a schema outside a transaction, a migrate that stopped between a table and its index leaves the table without it, and a copy that recorded itself over that table would keep the index missing.

Where php artisan migrate has already run the migrations from the package, copy the files from that directory under their own names instead of publishing them. The migrations table knows them by those names, so migrate leaves them alone.

With the migrations ignored, the package adds none of its jobs to your schedule, since each of them writes its tables. Once your copies of the migrations have run, schedule the three yourself:

use Illuminate\Support\Facades\Schedule;
use Pushery\FrontlineApi\Jobs\IngestMeter;
use Pushery\FrontlineApi\Jobs\PublishEverySheet;
use Pushery\FrontlineApi\Models\MeterCount;

Schedule::command('model:prune', ['--model' => [MeterCount::model()]])->daily()->withoutOverlapping(120)->onOneServer();
Schedule::job(new PublishEverySheet)->everyMinute()->withoutOverlapping(5)->onOneServer();
Schedule::job(new IngestMeter)->everyMinute()->withoutOverlapping(5)->onOneServer();

MeterCount::model() is the model frontline-api.models names in its place, or the package's own, as the package prunes it.

Environment variables​

A setting that reads an environment variable changes without publishing the file:

Environment variableSettingDefault
FRONTLINE_API_PRODUCTfrontline-api.productnone
FRONTLINE_API_ENVIRONMENTfrontline-api.environmentnone
FRONTLINE_API_STORE_CONNECTIONfrontline-api.store.connectionfrontline
FRONTLINE_API_COPIES_DISKfrontline-api.copies.diskfrontline
FRONTLINE_API_SIGNING_KEYfrontline-api.signing.keynone
FRONTLINE_API_SIGNING_KEY_IDfrontline-api.signing.key_idnone
FRONTLINE_API_SIGNING_NEXT_KEYfrontline-api.signing.next_keynone
FRONTLINE_API_SIGNING_NEXT_KEY_IDfrontline-api.signing.next_key_idnone
FRONTLINE_API_SHEETS_EXPIRES_AFTER_DAYSfrontline-api.sheets.expires_after_days7
FRONTLINE_API_BACKEND_MAX_CONCURRENCYfrontline-api.backend.max_concurrency32
FRONTLINE_API_METER_RETENTION_DAYSfrontline-api.meter.retention_days90
FRONTLINE_API_HEALTH_SHEET_STALE_AFTER_MINUTESfrontline-api.health.sheet_stale_after_minutes1320
FRONTLINE_API_HEALTH_METER_STALE_AFTER_MINUTESfrontline-api.health.meter_stale_after_minutes5
FRONTLINE_API_HOSTfrontline-api.hostnone
FRONTLINE_API_DECLARATION_LIMIT_CLASSfrontline-api.declaration.limit_classnone
FRONTLINE_API_DECLARATION_MAX_BODY_BYTESfrontline-api.declaration.max_body_bytes1048576
FRONTLINE_API_DECLARATION_TIMEOUT_SECONDSfrontline-api.declaration.timeout_seconds30
FRONTLINE_API_DECLARATION_STREAM_TIMEOUT_SECONDSfrontline-api.declaration.stream_timeout_seconds300
FRONTLINE_API_GATEWAY_SECRETfrontline-api.gateway.secretnone
FRONTLINE_API_GATEWAY_PREVIOUS_SECRETfrontline-api.gateway.previous_secretnone
FRONTLINE_API_GATEWAY_ADDRESSESfrontline-api.gateway.addresses127.0.0.1,::1
FRONTLINE_API_REQUIRE_SIGNATUREfrontline-api.gateway.require_signaturetrue
FRONTLINE_API_GATEWAY_MODEfrontline-api.gateway.modeenforce
FRONTLINE_API_HEALTH_PATHfrontline-api.gateway.health_path/frontline/health

A switch is off for false, 0, no and off, and on for true, 1, yes and on, written in any case and with spaces around it. A missing or an empty line in the .env keeps its default, and any other value stops the boot with an error that names the variable. A number that is no number, below its smallest useful value or above the largest a gateway takes, keeps the default: a lifetime of 3 to 7 days, since a gateway takes at most 7 and raises an alarm for a sheet that expires within 48 hours, a backend concurrency of up to 100,000, a timeout of up to 3,600 seconds and a body of up to 2^53 - 1 bytes. A published config holds its numbers as written: the route check names a backend concurrency, a timeout or a body limit there that lies past these bounds, and the product sheet does not go out while one does. A list takes its entries separated by commas. A product, an environment, a key label, the API host or a default limit class of another form reads as not set, and a setting without a default stays unset until you set it. The API host is a host name such as api.example.com, without a scheme or a port, and the route check names the setting while it reads as not set.

The store and the disk​

The gateways read the sheets from a Redis store, and from the object storage while the store is down. Add the Redis connection that frontline-api.store.connection names to the redis section of config/database.php, on the server your gateways read and in its database 0:

'frontline' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'username' => env('REDIS_USERNAME'),
'password' => env('REDIS_PASSWORD'),
'port' => env('REDIS_PORT', '6379'),
'database' => '0',
'options' => ['prefix' => ''],
],

The empty prefix matters. The gateways read every name exactly as the package writes it, and Laravel's default configuration puts a prefix before the keys of every connection. The package refuses a connection that does so, with a message that names the prefix.

So does database 0. A gateway reads only database 0 of its store, and products that share a store are kept apart by the start of every name, frontline:v1:<product>:<environment>:, never by the number of a database. Keep the connection on database 0 even where the application keeps the rest of its Redis data in another one, and give its url no database in the path or the query. The package refuses a connection that selects another database, with a message that names it.

Add the disk that frontline-api.copies.disk names to config/filesystems.php, on the bucket your gateways read while the store is down:

'frontline' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
],

Every sheet goes there first, byte for byte, under frontline/v1/<product>/<environment>/sheets/, and a copy the disk does not take stops the publication before the store sees it.

The gateways read that path from the top of the bucket, so give the disk no root and no prefix, and do not make it a scoped disk. The package refuses an s3 disk that would write the copies anywhere else, with a message that names the key it would have written.

Translations​

The package ships its texts in German, English, Spanish, French, Italian, Dutch and Portuguese. A regional locale reads the catalog of its language: pt-BR and pt-PT read pt, en-GB reads en, and so does a region nobody listed, such as fr-CA or de_AT. A catalog you publish for the region under lang/vendor/frontline-api/pt-BR/ wins over the language key by key, so a regional wording needs only the keys that differ. This holds for the frontline-api namespace alone: your own translations keep Laravel's lookup, which goes from the locale straight to app.fallback_locale.