1. Go to this page and download the library: Download johnkrovitch/configuration library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
johnkrovitch / configuration example snippets
use JK\Configuration\Configuration;
use Symfony\Component\OptionsResolver\OptionsResolver;
class MyConfiguration extends Configuration
{
public function configureOptions(OptionsResolver $resolver): void {
// Configure your options resolver here
$resolver->setDefaults([
'panda' => 'bamboo',
]);
}
}
use MyConfiguration;
class MyService {
public function myMethod(array $options): void
{
$configuration = new MyConfiguration();
$configuration->configure($options);
$configuration->get('panda'); // "bamboo"
$configuration->has('panda'); // true
$configuration->toArray(); // ['panda' => 'bamboo']
}
}
use MyConfiguration;
use Symfony\Component\OptionsResolver\OptionsResolver;
class MyService {
public function myMethod(array $options): void
{
$configuration = new MyConfiguration();
$resolver = new OptionsResolver();
// Do something with the resolver
// $resolver->setDefaults('...');
// Pass your custom resolver
$configuration->configure($options, $resolver);
$configuration->get('panda'); // Returns "bamboo"
$configuration->has('panda'); // Returns true
$configuration->toArray(); // Returns ['panda' => 'bamboo']
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.