Added config module

This commit is contained in:
Gregory Ballantine 2022-11-19 13:53:05 -05:00
parent 4a44aef764
commit 5fb463598a
4 changed files with 78 additions and 6 deletions

View File

@ -19,6 +19,7 @@
"slim/slim": "^4.11", "slim/slim": "^4.11",
"slim/psr7": "^1.6", "slim/psr7": "^1.6",
"php-di/php-di": "^6.4", "php-di/php-di": "^6.4",
"slim/twig-view": "^3.3" "slim/twig-view": "^3.3",
"hassankhan/config": "^3.0"
} }
} }

65
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "f0f0ba9a399b27b278723cab83da45ef", "content-hash": "e1122a37fac48e878d4d709af32db520",
"packages": [ "packages": [
{ {
"name": "fig/http-message-util", "name": "fig/http-message-util",
@ -62,6 +62,69 @@
}, },
"time": "2020-11-24T22:02:12+00:00" "time": "2020-11-24T22:02:12+00:00"
}, },
{
"name": "hassankhan/config",
"version": "3.0.1",
"source": {
"type": "git",
"url": "https://github.com/hassankhan/config.git",
"reference": "82421bb17d21cb0c10b98b89ea54aa4027adfc3f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/hassankhan/config/zipball/82421bb17d21cb0c10b98b89ea54aa4027adfc3f",
"reference": "82421bb17d21cb0c10b98b89ea54aa4027adfc3f",
"shasum": ""
},
"require": {
"php": ">=5.5.9"
},
"require-dev": {
"phpunit/phpunit": "~4.8.36 || ~5.7 || ~6.5 || ~7.5 || ~8.5",
"scrutinizer/ocular": "~1.1",
"squizlabs/php_codesniffer": "~2.2",
"symfony/yaml": "~3.4",
"yoast/phpunit-polyfills": "^1.0"
},
"suggest": {
"symfony/yaml": "~3.4"
},
"type": "library",
"autoload": {
"psr-4": {
"Noodlehaus\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Hassan Khan",
"homepage": "http://hassankhan.me/",
"role": "Developer"
}
],
"description": "Lightweight configuration file loader that supports PHP, INI, XML, JSON, and YAML files",
"homepage": "http://hassankhan.me/config/",
"keywords": [
"config",
"configuration",
"ini",
"json",
"microphp",
"unframework",
"xml",
"yaml",
"yml"
],
"support": {
"issues": "https://github.com/hassankhan/config/issues",
"source": "https://github.com/hassankhan/config/tree/3.0.1"
},
"time": "2022-03-26T19:37:50+00:00"
},
{ {
"name": "laravel/serializable-closure", "name": "laravel/serializable-closure",
"version": "v1.2.2", "version": "v1.2.2",

6
conf/defaults.json Normal file
View File

@ -0,0 +1,6 @@
{
"database": {
"driver": "sqlite",
"database": "./data/goliath.db"
}
}

View File

@ -1,6 +1,8 @@
<?php <?php
use DI\Container; use DI\Container;
use Noodlehaus\Config;
use Noodlehaus\Parser\Json;
use Slim\Factory\AppFactory; use Slim\Factory\AppFactory;
use Slim\Views\Twig; use Slim\Views\Twig;
use Slim\Views\TwigMiddleware; use Slim\Views\TwigMiddleware;
@ -8,13 +10,13 @@ use Slim\Views\TwigMiddleware;
require __DIR__ . '/../vendor/autoload.php'; require __DIR__ . '/../vendor/autoload.php';
// Load app configuration // Load app configuration
//$config = Config::load(__DIR__ . '/../conf/defaults.json'); $config = Config::load(__DIR__ . '/../conf/defaults.json');
// Create new container object and add our config object to it // Create new container object and add our config object to it
$container = new Container(); $container = new Container();
//$container->set('config', function () use ($config) { $container->set('config', function () use ($config) {
// return $config; return $config;
//}); });
// Set container to create App with on AppFactory // Set container to create App with on AppFactory
AppFactory::setContainer($container); AppFactory::setContainer($container);