Internal Settings

Settings are like config, but they're internal to Sprout and only last as long as the current process/request

Introduction

Sprout settings are a collection of values, similar to config, that is used internally by Sprout and its components. The values are contained within an instance of the class Sprout\Support\SettingsRepository which extends Laravel's default Illuminate\Config\Repository class which powers the config. These settings function almost identically to config, except they are added at runtime as needed, and not stored anywhere outside the request.

The purpose of these settings is to provide generic in-memory values that can be used by other parts of Sprout, without forcing different components to be aware of each other.

Accessing

The settings can be accessed on the core Sprout class, the Sprout facade, the sprout helper method, or the dedicated settings helper method.

1app(Sprout\Sprout::class)->settings();
2 
3Sprout\Facades\Sprout::settings();
4 
5Sprout\sprout()->settings();
6 
7Sprout\settings();

As the settings class extends Laravel's default config repository, you can both in the same way.

Presets

While the settings themselves can be whatever, there are a number of default settings that Sprout uses internally. These values can be used if needed, but it is highly recommended that you do not modify or remove them unless you're absolutely certain of what you're doing.

URL Path

This value contains core path components for the applications URL. It is set by the path identity resolver, and used by both the session and cookie service overrides. The setting key is url.path, which can be easily accessed through the constant Sprout\Support\Settings::URL_PATH. The value can be retrieved using the getUrlPath() method, and set using the setUrlPath() methods on the setting repository.

1// Getting
2settings()->getUrlPath();
3settings()->get(Settings::URL_PATH);
4 
5// Setting
6settings()->setUrlPath('this/that');
7settings()->set(Settings::URL_PATH, 'this/that');

URL Domain

This value contains the domain component for the application URL. It is set by the subdomain identity resolver, and used by both the session and cookie service overrides. The setting key is url.domain, which can be easily accessed through the constant Sprout\Support\Settings::URL_DOMAIN. The value can be retrieved using the getUrlDomain() method, and set using the setUrlDomain() methods on the setting repository.

1// Getting
2settings()->getUrlDomain();
3settings()->get(Settings::URL_DOMAIN);
4 
5// Setting
6settings()->setUrlDomain('this.that');
7settings()->set(Settings::URL_DOMAIN, 'this.that');

No Database Override

This value is a bool that's used to signify whether overrides should override database-based drivers and components. This value contains the domain component for the application URL. It is set by the subdomain identity resolver, and used by both the session and cookie service overrides. The setting key is url.domain, which can be easily accessed through the constant Sprout\Support\Settings::URL_DOMAIN. The value can be retrieved using the getUrlDomain() method, and set using the setUrlDomain() methods on the setting repository.

1// Getting
2settings()->getUrlDomain();
3settings()->get(Settings::URL_DOMAIN);
4 
5// Setting
6settings()->setUrlDomain(false);
7settings()->set(Settings::URL_DOMAIN, false);

This value is al bool and is the same as Laravel's session.secure config setting, which is used to control the defaults for cookies as well as session cookies. It is currently used by both the session and cookie service overrides. The setting key is cookie.secure, which can be easily accessed through the constant Sprout\Support\Settings::COOKIE_SECURE. The value can be retrieved using the shouldCookieBeSecure() method, and set using the setCookieSecure() methods on the setting repository.

1// Getting
2settings()->shouldCookieBeSecure();
3settings()->get(Settings::COOKIE_SECURE);
4 
5// Setting
6settings()->setCookieSecure(false);
7settings()->set(Settings::COOKIE_SECURE, false);

This value is the same as Laravel's session.same_site config setting, which is used to control the defaults for cookies as well as session cookies, so it should be one of the string values strict, lax, and none, or it can be null. It is currently used by both the session and cookie service overrides. The setting key is cookie.same_site, which can be easily accessed through the constant Sprout\Support\Settings::COOKIE_SAME_SITE. The value can be retrieved using the getCookieSameSite() method, and set using the setCookieSameSite() methods on the setting repository.

1// Getting
2settings()->getCookieSameSite();
3settings()->get(Settings::COOKIE_SAME_SITE);
4 
5// Setting
6settings()->setCookieSameSite('lax');
7settings()->set(Settings::COOKIE_SAME_SITE, 'lax');