PHP Classes

File: demo/index.php

Recommend this page to a friend!
  Classes of Boss Ibrahim Mussa   Options Resolver   demo/index.php   Download  
File: demo/index.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Options Resolver
Configure objects with option arrays
Author: By
Last change:
Date: 1 year ago
Size: 603 bytes
 

Contents

Class file image Download
<?php
/*
 * Copyright (c) 2022.
 * The OptionsResolver component helps you configure objects with option arrays. It supports default values, option constraints and lazy options.
 */

use Wepesi\Demo\Database;

include
__DIR__."/../vendor/autoload.php";
include
__DIR__."/Database.php";

$database = new Database([
   
'dbname' => 'app',
]);
// Uncaught InvalidArgumentException: The required option "username" is missing.

// $database = new Database([
// 'host' => 'localhost',
// 'dbname' => 'app',
// 'username' => 'root',
// 'password' => 'root',
// ]);
var_dump($database->options);