Configuration¶
The dispatcher framework can be configured passing configuration statements as an associative array when creating a new \Comodojo\Dispatcher\Dispatcher
instance.
1 2 3 4 | use \Comodojo\Dispatcher\Dispatcher;
$dispatcher = new \Comodojo\Dispatcher\Dispatcher([
// configuration parameters here!
]);
|
A init time, the configuration is used to create basic objects (e.g. models, cache provider) and can be changed at any time accessing the configuration object (that will be an instance of ComodojoFoundationBasicConfiguration class).
1 2 3 4 5 6 7 8 9 10 11 | // get the configuration object
$configuration = $dispatcher->getConfiguration();
// get the base-path value from actual configuration
$base_path = $configuration->get('base-path');
// set the my-param configuration item using standard notation
$configuration->set('my-param', 'foo');
// set the my->remote->url nested configuration item using dot notation
$configuration->set('my.remote.url', 'https://example.com')
|
Note
For more information about the \Comodojo\Foundation\Base\Configuration
class, see the comodojo/foundation documentation.
Configuration parameters¶
Following the list of configuration statement currently supported by the framework.
(bool) enabled [default: true]
Enable or disable the framework (i.e. if not enabled, dispatcher cannot serve any request).
(int) disabled-status [default: 503]
In case not enabled, the HTTP status to return to clients.
(string) disabled-message [default: Dispatcher offline]
In case not enabled, the HTTP body to return to clients.
(string) encoding [default: UTF-8]
Active char encoding.
(bool) routing-table-cache [default: true]
Enable or disable the caching of the routing table.
(int) routing-table-ttl [default: 86400]
The ttl for the routing table cache.
(array) supported-http-methods (default: null)
This setting could be used to restring (or enhance) the support for HTTP methods.
If not defined, the framework will allow the following http verbs:
- GET
- PUT
- POST
- DELETE
- OPTIONS
- HEAD
- TRACE
- CONNECT
- PURGE
(array) log
Logger configuration, input for the LogManager::createFromConfiguration()
method (for more information, see the comodojo/foundation documentation)
An example schema:
1 2 3 4 5 6 7 8 | log:
enable: true
name: dispatcher
providers:
local:
type: StreamHandler
level: debug
stream: logs/dispatcher.log
|
(array) cache
Cache manager of provider configuration, input for the SimpleCacheManager::createFromConfiguration()
method (for more information, see the comodojo/cache documentation)
An example schema:
1 2 3 4 5 6 7 | cache:
enable: true
pick_mode: PICK_FIRST
providers:
local:
type: Filesystem
cache_folder: cache
|
Automatic configuration parameters¶
The following (basic) configuration parameters are computed and included in the configuration at init time.
Note
The user configuration has precedence over the automatic one: if one of these parameter is included in the user configuration, its value will overwrite the automatic one.
(string) base-path
The base path of the project directory (i.e. the root of the vendor folder).
(string) base-url
The current URL used to contact the framework.
(string) base-uri
The full URI used to contact the framework.
(string) base-location
The relative path before the entry point (i.e. the index.php file).