Site objects are constructed with Environments, and represent distinct Outpost installations. In almost every case it will be advantageous to extend the base Site
class to the unique needs of the project.
The Site
class contains one transitive method: invoke()
. It receives a Request
object and is expected to return a Response
object, otherwise an InvalidResponseException
is thrown.
The static respond()
method accepts an Environment and an optional Request object. It attempts to:
- Instantiate a Site within the Environment
- Call the Site's
invoke()
method, with the provided Request or one supplied by the Environment object - Send the returned Response
An Outpost site contains these resources:
- The
getClient()
method returns the Web Client, an instance ofGuzzl\Client
, for making HTTP requests to other sites. - The
getCache()
method returns the site Cache, an instance ofStash\Pool
. The Web Client will attempt to store the results ofGET
requests in the Cache, unless otherwise configured. - The
getLog()
method returns the site Log, aMonolog\Logger
instance. In development environments, the log is written tolog/outpost.log
by default.
An Outpost site will attempt to load data from two JSON files:
outpost.json
should contain data that is safe to store in a repository. Data from this file is available via thegetSetting()
method.secrets.json
should be used to store sensitive data, such as passwords and API keys. Data from this file is available via thegetSecret()
method.