PHP Classes

File: usage/usage.php

Recommend this page to a friend!
  Classes of Miraz Mac   Pure PHP Config   usage/usage.php   Download  
File: usage/usage.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Pure PHP Config
Access configuration values stored in PHP scripts
Author: By
Last change:
Date: 3 years ago
Size: 841 bytes
 

Contents

Class file image Download
<?php

use MirazMac\PurePhpConfig\PurePhpConfig;

require_once
'../vendor/autoload.php';

$config = new PurePhpConfig(__DIR__ . '/config');

// Access a value
var_dump($config->get('app.url'));


// Delete a key
var_dump($config->delete('app.twig.auto'));

echo
"<br>";

// Access a nested value using dot notation
var_dump($config->get('app.twig.cache'));

echo
"<br>";

// Check if a key exists
var_dump($config->exists('app.twig'));

echo
"<br>";

// Provided with only namespace, so will return all data as array
var_dump($config->get('app'));
echo
"<br>";

// Set a value
var_dump($config->set('app.url', 'https://google.com'));

echo
"<br>";
// Set a nested value using dot notation
var_dump($config->set('app.twig.cache', false));

echo
"<br>";
// Replace an entire namespace data
var_dump($config->set('app', ['name' => 'NewApp']));