Skip to main content
A single site needs only .env. The install writes it for you:
Terminal
It adds these lines:
.env
string
required
The site’s slug: the acme in its key, fsk_acme_…. A key filed under another slug is refused, naming the right one.
string
required
The site’s public origin: https:// and the host it answers on, with no path, query or credentials. A redirect is never followed; plain http:// reaches only localhost or a private service name.
string
required
fsk_<site>_<key id>_<secret>, as the site showed it. An empty value is refused, never taken as the public.
string
fss_…, when the key signs. With a secret, the client signs every request it can, uploads by their SHA-256. Signing requests lists which requests must be signed.

Or keep the key in your database

The key and signing secret encrypted in a table the package ships, replaced without touching .env.

The default site

Attract::x() reaches the default

The site FETCHSKI_ATTRACT_SITE names, or, when that is unset, the one site configured (with the key in the database, the table’s one row).

Attract::site('slug') reaches any other

Its client is made once per slug.

No default, no slug: a clear error

No default site: set FETCHSKI_ATTRACT_SITE, or call Attract::site('<slug>').

More sites

List them in config/fetchski-attract.php, beside the env one:
config/fetchski-attract.php
Leave api_key out for a public site (the env site always needs its key). api_signing (none, writes or all) is optional: it only has the client refuse what the key can’t send.
Read keys in a config file, never with env() in app code: once your app’s config is cached, env() answers null outside the config files.

Checked at boot, and on demand

At boot, every entry must build and default must name a configured site. The first mistake throws one SiteConfigurationError saying what to fix. (Skipped in unit tests, and with no sites.) On demand, run the same check, then a call to the site: reachable, the key accepted, and the clocks within a minute (signatures allow five). It exits 1 on any failure:
Terminal
Name a site to check another one:
Terminal

The package’s settings

Next: calling the API

Arguments, answers, lists, jobs and uploads.