-
-
Notifications
You must be signed in to change notification settings - Fork 6
Configuration
Configuration files are used to store data that can change between environments, such as database connection details, API keys, timezone information, and so on. It is common practice to have different configuration values based on the environment where the application is running.
All configuration files for WebEngine applications are stored in the project's root directory as .ini
files, and a default config is supplied by WebEngine to set all config values to meaningful defaults.
Multiple config files can exist which introduce new config values or override existing values. All values can also be overridden by setting environment variables on the server.
The following order is used to override configuration values:
- The WebEngine default config:
/vendor/phpgt/webengine/config.default.ini
- The project's default config:
config.ini
- Development config:
config.dev.ini
- Deployment config:
config.deploy.ini
- Production config:
config.prod.ini
- Environment variables
// Sections.
// Use underscore to separate sections.
Throughout WebEngine, global variables are not permitted. Config values can usually be seen as global state, meaning that they can be read from anywhere in your code (or your code's dependencies). Rather than passing around important API keys and database passwords to every class in the application, a single instance of the Config
class is passed to your Page Logic entrypoint, allowing you to decide which classes of the application get passed the configuration, and which sections of the configuration they have access to.
From within a Logic class, $this->config
is set to an instance of the Config
object. The config object has two mechanisms for retrieving config data: get
and getSection
.
The get
method allows the use of dot-notation to grab the value of some config by name.
// Store in web server.
// Bool (on off, etc)
- Request-response lifecycle
- Running your application
- Project layout
- Application architecture
- Web servers
- URIs
- Page view
- Dynamic URIs and pages
- Headers and footers
- Page logic
- Protected globals
- User input
- Cookies
- Sessions
- DOM manipulation
- Custom HTML components
- DOM templates
- Binding data to the DOM
- Database
- Client side assets
- API Webservices
- Security
- Configuration
- Build system
- Coding styleguide