Recommend this page to a friend! |
Download |
Info | Documentation | Files | Install with Composer | Download | Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2023-11-13 (10 months ago) | Not enough user ratings | Total: 58 | All time: 10,535 This week: 65 |
Version | License | PHP version | Categories | |||
lawondyss-config 1.0.1 | MIT/X Consortium ... | 7.1 | Configuration, PHP 7 |
Description | Author | ||||||||||||||||||||||
This package provides a base class for creating configuration objects. |
|
Base class for creating own class of configuration. Better than a associative array :-)
Over Composer
composer require lawondyss/config
class DbConfig extend Lawondyss\Config
{
public string $driver;
public string $host;
public string $database;
public string $username;
public string $password;
public string $charset;
}
$dbConfig = DbConfig::fromArray([
'driver' => 'mysqli',
'host' => 'localhost',
'database' => 'example',
'username' => 'root',
'password' => 'root',
'charset' => 'utf8'
]);
Simple get and set individual option.
$charset = $dbConfig->charset;
$dbConfig->charset = 'latin1';
Is implemented array access.
$pass = $dbConfig['password'];
$dbConfig['password'] = '*';
If you want default values, then defined in class.
class DbConfig extend Lawondyss\Config
{
public string $driver = 'mysqli';
public string $host = 'localhost';
public string $database;
public string $username;
public string $password;
public string $charset = 'utf8';
}
$defaultConfig = new DbConfig;
Is possible "merge" with a customized options.
$lipsumDbConfig = $defaultConfig->withOptions([
'database' => 'lipsum',
'username' => 'lorem',
'password' => 'ipsum',
]);
If another code use options as associative array:
$dibi = new Dibi\Connection($lipsumDbConfig->toArray());
MIT
Files (9) |
File | Role | Description | ||
---|---|---|---|---|
.github (1 directory) | ||||
src (1 directory) | ||||
tests (2 files) | ||||
composer.json | Data | Auxiliary data | ||
LICENSE.md | Lic. | License text | ||
phpcs.xml | Data | Auxiliary data | ||
README.md | Doc. | Documentation |
Files (9) | / | src | / | Config |
File | Role | Description |
---|---|---|
Config.php | Class | Class source |
UndefinedOption.php | Class | Class source |
Files (9) | / | tests |
File | Role | Description |
---|---|---|
bootstrap.php | Aux. | Auxiliary script |
ConfigTest.php | Class | Class source |
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
Install with Composer |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.