\Cake\Core\Configure\EnginePhpConfig

PHP engine allows Configure to load configuration values from files containing simple PHP arrays.

Files compatible with PhpConfig should return an array that contains all of the configuration data contained in the file.

An example configuration file would look like::

<?php
return [
    'debug' => 0,
    'Security' => [
        'salt' => 'its-secret'
    ],
    'App' => [
        'namespace' => 'App'
    ]
];

Summary

Methods
Properties
Constants
__construct()
read()
dump()
No public properties found
No constants found
_getFilePath()
$_path
$_extension
N/A
No private methods found
No private properties found
N/A

Properties

$_path

$_path : string

The path this engine finds files on.

Type

string

$_extension

$_extension : string

File extension.

Type

string

Methods

__construct()

__construct(string|null  $path = null) 

Constructor for PHP Config file reading.

Parameters

string|null $path

The path to read config files from. Defaults to CONFIG.

read()

read(string  $key) : array

Read a config file and return its contents.

Files with . in the name will be treated as values in plugins. Instead of reading from the initialized path, plugin keys will be located using Plugin::path().

Setting a $config variable is deprecated. Use return instead.

Parameters

string $key

The identifier to read from. If the key has a . it will be treated as a plugin prefix.

Throws

\Cake\Core\Exception\Exception

when files don't exist or they don't contain $config. Or when files contain '..' as this could lead to abusive reads.

Returns

array —

Parsed configuration values.

dump()

dump(string  $key, array  $data) : boolean

Converts the provided $data into a string of PHP code that can be used saved into a file and loaded later.

Parameters

string $key

The identifier to write to. If the key has a . it will be treated as a plugin prefix.

array $data

Data to dump.

Returns

boolean —

Success

_getFilePath()

_getFilePath(string  $key, boolean  $checkExists = false) : string

Get file path

Parameters

string $key

The identifier to write to. If the key has a . it will be treated as a plugin prefix.

boolean $checkExists

Whether to check if file exists. Defaults to false.

Throws

\Cake\Core\Exception\Exception

When files don't exist or when files contain '..' as this could lead to abusive reads.

Returns

string —

Full file path