All of the provided application skeletons are already pre-configured using optimal settings. You can edit any of the settings
by editing the file(s) in app/config/
.
If config file does not exist - create it using
<?php return [];
as a base.
Web and GRPC templates use DotEnv extension to read environment values from .env
file located in the root of your project.
# Debug mode set to TRUE disables view caching and enables higher verbosity.
DEBUG=true
# Set to application-specific value, used to encrypt/decrypt cookies, etc.
ENCRYPTER_KEY={encrypt-key}
# Set to TRUE to disable confirmation in `migrate` commands.
SAFE_MIGRATIONS=true
You can access these values using Spiral\Boot\EnvironmentInterface
or via a short function env
.
public function index(EnvironmentInterface $env)
{
dump($env->get('ENCRYPTER_KEY'));
dump(env('ENCRYPTER_KEY'));
}
The default component configuration located inside the related Bootloader. You can alter such configuration using other bootloaders (see Auto-Configuration) or by creating a default configuration file in app/config
.
Each of the documentation sections will include the content of the default component configuration.
Web and GRPC skeletons include app/config/database.php
config file:
use Cycle\Database\Driver;
return [
'default' => 'default',
'databases' => [
// database name => driver
'default' => ['driver' => 'runtime'],
],
'drivers' => [
// driver name => options
'runtime' => [
'driver' => Driver\SQLite\SQLiteDriver::class,
'connection' => 'sqlite:' . directory('runtime') . 'runtime.db',
'profiling' => true,
],
]
];
Identically, you can edit any configuration for any of component. For example, we can change default HTTP headers
via app/config/http.php
:
return [
'headers' => [
'Server' => 'Spiral',
'Content-Type' => 'text/html; charset=UTF-8'
],
];
To find which config file corresponds to the proper config object, check the value of CONFIG constant:
final class HttpConfig extends InjectableConfig
{
const CONFIG = 'http';
// ...
See the reference for each component configuration in the related documentation section.