ilyaplot / containers
Simple containers package
Installs: 2 427
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:extension
Requires
- php: >=5.6
This package is not auto-updated.
Last update: 2023-05-30 08:19:40 UTC
README
Installation
The preferred way to install this extension is through composer. Just run
php composer.phar require --prefer-dist ilyaplot/containers
or add
"ilyaplot/containers": "*"
to the require section of your composer.json
file.
Usage Container exaple:
$container = new \ilyaplot\Container(['value' => 100]); $container->value1 = 200; echo $container->value; // 100 echo $container->value1; // 200 echo $container['value1']; // 200 foreach ($container as $key=>$value) { echo $key . ':' . $value; // value:100 and value1:200 } echo count($container); // 2 echo (string) $container; // {"value":100, "value2":200}
Usage Config exaple:
File: config.php:
<?php return ['hostname' => '127.0.0.1', 'username' => 'guest'];
Usage:
// Example config.php: $config = new \ilyaplot\Config('config.php', ['password' => 'qwe123', 'username' => 'admin']); echo $config->hostname; // 127.0.0.1 echo $config->password; // qwe123 echo $config->username; // guest echo count($config); // 3 $config = new \ilyaplot\Config('config.php', [], ['required_param']); // throws ContainerException with message: Required param(s) "required_param" has not been set.