1. Go to this page and download the library: Download coolephp/options-resolver 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/ */
coolephp / options-resolver example snippets
php
use Symfony\Component\OptionsResolver\OptionsResolver;
class Email
{
private $options;
/**
* Email constructor.
*
* @param array $options
*/
public function __construct(array $options = [])
{
$this->setOptions($options);
}
/**
* @return mixed
*/
public function getOptions()
{
return $this->options;
}
/**
* @param array $options
*/
public function setOptions(array $options): void
{
$this->options = configure_options($options, function (OptionsResolver $resolver) {
$resolver->setDefaults([
'host' => 'smtp.example.org',
'username' => 'user',
'password' => 'password',
'port' => 25,
]);
$resolver->setRequired(['host', 'username', 'password', 'port']);
$resolver->setAllowedTypes('host', 'string');
$resolver->setAllowedTypes('username', 'string');
$resolver->setAllowedTypes('password', 'string');
$resolver->setAllowedTypes('port', 'int');
});
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.