Getting started
Routing and controllers
Command line
Databases (SQL)
Databases (NoSQL)
Security
Packages
Learn more
- Array helper
- Caching
- Collections
- Command bus (deprecated)
- Command, event and query buses
- Date and time
- Events (deprecated)
- File system
- HTML helper
- Humanizer
- Image manipulation
- Internationalization
- Logging
- Number helper
- Pagination
- Retry helper
- Sessions
- String helper
- URL builder
- UUID helper
- Validation
- Views
Official packages
Configuration
The configuration of the Mako core is done in the app/init.php
file. This is where you set the error reporting level and define the paths to the application and vendor directories.
All of the remaining application configuration is done by editing the files that are located in the app/config
directory.
Config files
Mako config files are just simple arrays. In addition to the core config files that are created, you can create your own custom config files:
<?php
// app/config/redis.php
return
[
'key_1' => 'value',
'key_2' => 'value',
];
And loading a config file is done by using the get
method.
$config = $this->config->get('redis'); // Loads the app/config/redis.php file
You can also fetch config items using dot notation
. If we are using the example above, you can fetch key_1
in this manner:
$default = $this->config->get('redis.key_1');
It is also possible to override settings or add new configurations at runtime:
// Adds a new Crypto configuration named "user" that you can
// use when creating a Crypto instance "Crypto::getInstance('user');"
$this->config->set('crypto.configurations.user',
[
'library' => 'openssl',
'cipher' => 'AES-256-OFB',
'key' => 'ksMGBr_yR>=IiRicJFUhD4XlRnE%|11mvRGNJsD',
]);
Removing the custom configuration is done using the remove
method:
$this->config->remove('crypto.configurations.user');
Setting configuration at runtime is not always possible. Some components such as the connections managers (database, redis, etc...) will cache the settings once they get loaded. You can override them using their
addConfiguration
andremoveConfiguration
methods instead.
Security First
Many developers have made mistakes with committing config files to their repositories. In some cases those repositories are made public and there are credential sniffing bots that find exposed credentials. When you are dealing with our Mako application, please take caution into what files you commit to the repository and which files you add to your .gitignore
or equivalent ignore file for your VCS.
Any configuration files that hold an API key, a username/password, an encryption key or any other type of sensitive data should not be committed to your repository!
Environment aware configuration
Mako supports environment aware configuration. This means that you can have separate configuration files for your different environments. All you have to do is create a subdirectory with the name of your environment in the app/config
directory and copy the environment specific files into it.
Setting the environment
Setting the environment in Apache:
SetEnv MAKO_ENV dev
Setting the environment in Nginx:
fastcgi_param MAKO_ENV dev;
Setting the environment in a linux/unix shell:
export MAKO_ENV=dev # for Bourne, bash, and related shells
setenv MAKO_ENV=dev # for csh and related shells
You can also manually set the environment in the CLI using the env option.
php reactor <command> --env=dev
Using the above methods to set up the dev
environment, it will now read your configurations from app/config/dev/
. If you changed the environment to prod
it will pull from app/config/prod/
instead.
Package configuration
Check out the package documentation for more information regarding package configuration.