originphp / configurable
OriginPHP Configurable
Installs: 18 086
Dependents: 10
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=7.3.0
Requires (Dev)
- phpunit/phpunit: ^9.2
This package is auto-updated.
Last update: 2025-02-04 21:11:19 UTC
README
Configurable traits to add default config and setters and getters.
Installation
To install this package
$ composer require originphp/configurable
Usage
Both instance and static traits are available.
Set defaultConfig
property
use Origin\Configurable\InstanceConfigurable as Configurable; class MyObject { use Configurable; protected $defaultConfig = [ 'foo' => 'bar' ]; }
To get a value from the config:
$value = $this->config('foo'); // bar
To all of the values from the config
$array = $this->config();
To set a value in the config:
$this->config('foo','bar'); $this->config(['foo'=>'bar']);
To set multiple values (merges config)
$this->config(['foo'=>'bar']);