Add some defines for global constants
This commit is contained in:
parent
9bf80dbf9e
commit
80c54eefc2
@ -11,7 +11,8 @@
|
||||
"league/config": "^1.2",
|
||||
"monolog/monolog": "^3.6",
|
||||
"slim/flash": "^0.4.0",
|
||||
"odan/session": "^6.1"
|
||||
"odan/session": "^6.1",
|
||||
"dotenv-org/phpdotenv-vault": "^0.2.4"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^11.1",
|
||||
|
276
app/composer.lock
generated
276
app/composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "e53cd4e029d379845d39165f4cc34653",
|
||||
"content-hash": "7c62ce964dc867d3d860dc89275187b0",
|
||||
"packages": [
|
||||
{
|
||||
"name": "dflydev/dot-access-data",
|
||||
@ -81,6 +81,59 @@
|
||||
},
|
||||
"time": "2022-10-27T11:44:00+00:00"
|
||||
},
|
||||
{
|
||||
"name": "dotenv-org/phpdotenv-vault",
|
||||
"version": "v0.2.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/dotenv-org/phpdotenv-vault.git",
|
||||
"reference": "5fca3eb6c6a0e9bd320a72781c6a6f9342ab5cd4"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/dotenv-org/phpdotenv-vault/zipball/5fca3eb6c6a0e9bd320a72781c6a6f9342ab5cd4",
|
||||
"reference": "5fca3eb6c6a0e9bd320a72781c6a6f9342ab5cd4",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.1.3 || ^8.0",
|
||||
"vlucas/phpdotenv": "^5.5"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^9.0|^8.0|^7.0|6.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"DotenvVault\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "dotenv",
|
||||
"email": "mot@dotenv.org",
|
||||
"homepage": "https://github.com/dotenv-org"
|
||||
}
|
||||
],
|
||||
"description": "Load environment variables from encrypted .env.vault files",
|
||||
"keywords": [
|
||||
"configurations",
|
||||
"dotenv",
|
||||
"dotenv-vault",
|
||||
"env",
|
||||
"environment",
|
||||
"environment variables"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/dotenv-org/phpdotenv-vault/issues",
|
||||
"source": "https://github.com/dotenv-org/phpdotenv-vault/tree/v0.2.4"
|
||||
},
|
||||
"time": "2023-11-04T06:15:17+00:00"
|
||||
},
|
||||
{
|
||||
"name": "fig/http-message-util",
|
||||
"version": "1.1.5",
|
||||
@ -137,6 +190,68 @@
|
||||
},
|
||||
"time": "2020-11-24T22:02:12+00:00"
|
||||
},
|
||||
{
|
||||
"name": "graham-campbell/result-type",
|
||||
"version": "v1.1.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/GrahamCampbell/Result-Type.git",
|
||||
"reference": "fbd48bce38f73f8a4ec8583362e732e4095e5862"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/GrahamCampbell/Result-Type/zipball/fbd48bce38f73f8a4ec8583362e732e4095e5862",
|
||||
"reference": "fbd48bce38f73f8a4ec8583362e732e4095e5862",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.2.5 || ^8.0",
|
||||
"phpoption/phpoption": "^1.9.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^8.5.34 || ^9.6.13 || ^10.4.2"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"GrahamCampbell\\ResultType\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Graham Campbell",
|
||||
"email": "hello@gjcampbell.co.uk",
|
||||
"homepage": "https://github.com/GrahamCampbell"
|
||||
}
|
||||
],
|
||||
"description": "An Implementation Of The Result Type",
|
||||
"keywords": [
|
||||
"Graham Campbell",
|
||||
"GrahamCampbell",
|
||||
"Result Type",
|
||||
"Result-Type",
|
||||
"result"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/GrahamCampbell/Result-Type/issues",
|
||||
"source": "https://github.com/GrahamCampbell/Result-Type/tree/v1.1.2"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/GrahamCampbell",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/graham-campbell/result-type",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2023-11-12T22:16:48+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laravel/serializable-closure",
|
||||
"version": "v1.3.3",
|
||||
@ -948,6 +1063,81 @@
|
||||
],
|
||||
"time": "2023-11-02T10:04:50+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpoption/phpoption",
|
||||
"version": "1.9.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/schmittjoh/php-option.git",
|
||||
"reference": "80735db690fe4fc5c76dfa7f9b770634285fa820"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/schmittjoh/php-option/zipball/80735db690fe4fc5c76dfa7f9b770634285fa820",
|
||||
"reference": "80735db690fe4fc5c76dfa7f9b770634285fa820",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.2.5 || ^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"bamarni/composer-bin-plugin": "^1.8.2",
|
||||
"phpunit/phpunit": "^8.5.34 || ^9.6.13 || ^10.4.2"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"bamarni-bin": {
|
||||
"bin-links": true,
|
||||
"forward-command": true
|
||||
},
|
||||
"branch-alias": {
|
||||
"dev-master": "1.9-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"PhpOption\\": "src/PhpOption/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"Apache-2.0"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Johannes M. Schmitt",
|
||||
"email": "schmittjoh@gmail.com",
|
||||
"homepage": "https://github.com/schmittjoh"
|
||||
},
|
||||
{
|
||||
"name": "Graham Campbell",
|
||||
"email": "hello@gjcampbell.co.uk",
|
||||
"homepage": "https://github.com/GrahamCampbell"
|
||||
}
|
||||
],
|
||||
"description": "Option Type for PHP",
|
||||
"keywords": [
|
||||
"language",
|
||||
"option",
|
||||
"php",
|
||||
"type"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/schmittjoh/php-option/issues",
|
||||
"source": "https://github.com/schmittjoh/php-option/tree/1.9.2"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/GrahamCampbell",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/phpoption/phpoption",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2023-11-12T21:59:55+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/container",
|
||||
"version": "2.0.2",
|
||||
@ -2090,6 +2280,90 @@
|
||||
}
|
||||
],
|
||||
"time": "2024-05-16T10:04:27+00:00"
|
||||
},
|
||||
{
|
||||
"name": "vlucas/phpdotenv",
|
||||
"version": "v5.6.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/vlucas/phpdotenv.git",
|
||||
"reference": "2cf9fb6054c2bb1d59d1f3817706ecdb9d2934c4"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/2cf9fb6054c2bb1d59d1f3817706ecdb9d2934c4",
|
||||
"reference": "2cf9fb6054c2bb1d59d1f3817706ecdb9d2934c4",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-pcre": "*",
|
||||
"graham-campbell/result-type": "^1.1.2",
|
||||
"php": "^7.2.5 || ^8.0",
|
||||
"phpoption/phpoption": "^1.9.2",
|
||||
"symfony/polyfill-ctype": "^1.24",
|
||||
"symfony/polyfill-mbstring": "^1.24",
|
||||
"symfony/polyfill-php80": "^1.24"
|
||||
},
|
||||
"require-dev": {
|
||||
"bamarni/composer-bin-plugin": "^1.8.2",
|
||||
"ext-filter": "*",
|
||||
"phpunit/phpunit": "^8.5.34 || ^9.6.13 || ^10.4.2"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-filter": "Required to use the boolean validator."
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"bamarni-bin": {
|
||||
"bin-links": true,
|
||||
"forward-command": true
|
||||
},
|
||||
"branch-alias": {
|
||||
"dev-master": "5.6-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Dotenv\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Graham Campbell",
|
||||
"email": "hello@gjcampbell.co.uk",
|
||||
"homepage": "https://github.com/GrahamCampbell"
|
||||
},
|
||||
{
|
||||
"name": "Vance Lucas",
|
||||
"email": "vance@vancelucas.com",
|
||||
"homepage": "https://github.com/vlucas"
|
||||
}
|
||||
],
|
||||
"description": "Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.",
|
||||
"keywords": [
|
||||
"dotenv",
|
||||
"env",
|
||||
"environment"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/vlucas/phpdotenv/issues",
|
||||
"source": "https://github.com/vlucas/phpdotenv/tree/v5.6.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/GrahamCampbell",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/vlucas/phpdotenv",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2023-11-12T22:43:29+00:00"
|
||||
}
|
||||
],
|
||||
"packages-dev": [
|
||||
|
@ -17,9 +17,20 @@ use Slim\Views\TwigMiddleware;
|
||||
use Slim\Psr7\Factory\ResponseFactory;
|
||||
|
||||
use Slovocast\Routes;
|
||||
use Slovocast\Configuration\SiteInformationSchema;
|
||||
use Slovocast\Configuration\DatabaseConnectionSchema;
|
||||
use Slovocast\Configuration\SessionSchema;
|
||||
use Slovocast\Configuration\{
|
||||
SiteInformationSchema,
|
||||
DatabaseConnectionSchema,
|
||||
SessionSchema
|
||||
};
|
||||
use Slovocast\Domain\Repository\{
|
||||
UserRepositoryInterface,
|
||||
UserRepository
|
||||
};
|
||||
use Slovocast\Infrastructure\{
|
||||
DatabaseConnectionInterface,
|
||||
User\UserAuthorizationInterface,
|
||||
User\BasicUserAuthorization
|
||||
};
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Monolog\Logger;
|
||||
@ -29,6 +40,16 @@ use Odan\Session\PhpSession;
|
||||
use Odan\Session\SessionInterface;
|
||||
use Odan\Session\SessionManagerInterface;
|
||||
|
||||
/**
|
||||
* Defines here are used globally
|
||||
*/
|
||||
define('APP_ROOT_DIR', __DIR__ . '/..');
|
||||
define('APP_SRC_DIR', __DIR__);
|
||||
define('APP_PUBLIC_DIR', __DIR__ . '/../public');
|
||||
define('APP_TEMPLATES_DIR', __DIR__ . '/../templates');
|
||||
define('APP_LOGS_DIR', __DIR__ . '/../var/logs');
|
||||
define('APP_TEMP_DIR', __DIR__ . '/../var/temp');
|
||||
|
||||
class Bootstrap
|
||||
{
|
||||
/**
|
||||
@ -39,6 +60,7 @@ class Bootstrap
|
||||
protected static function initConfig(): Configuration
|
||||
{
|
||||
$config = new Configuration();
|
||||
$dotenv = \DotenvVault\DotenvVault::createImmutable(APP_ROOT_DIR);
|
||||
|
||||
// set all configuration details
|
||||
$config->addSchema('site', SiteInformationSchema::getSchema());
|
||||
@ -74,17 +96,17 @@ class Bootstrap
|
||||
$config = self::initConfig();
|
||||
$containerBuilder->addDefinitions([
|
||||
'config' => $config,
|
||||
// more DI stuff
|
||||
'flash' => function (ContainerInterface $container) {
|
||||
return $container->get(SessionInterface::class)->getFlash();
|
||||
},
|
||||
LoggerInterface::class => function() {
|
||||
$logger = new Logger();
|
||||
$logger->pushHandler(
|
||||
new StreamHandler(__DIR__ . '/var/logs', Level::Warning)
|
||||
new StreamHandler(APP_LOG_DIR, Level::Warning)
|
||||
);
|
||||
return $logger;
|
||||
},
|
||||
|
||||
/**
|
||||
* Session and Flash classes here
|
||||
*/
|
||||
SessionManagerInterface::class => function (ContainerInterface $container) {
|
||||
return $container->get(SessionInterface::class);
|
||||
},
|
||||
@ -92,9 +114,31 @@ class Bootstrap
|
||||
$options = $container->get('config')->get('session');
|
||||
return new PhpSession($options);
|
||||
},
|
||||
'flash' => function (ContainerInterface $container) {
|
||||
return $container->get(SessionInterface::class)->getFlash();
|
||||
},
|
||||
|
||||
/**
|
||||
* Application DI
|
||||
*/
|
||||
ResponseFactoryInterface::class => function (ContainerInterface $container) {
|
||||
return new ResponseFactory();
|
||||
},
|
||||
|
||||
/**
|
||||
* Database Connections
|
||||
*/
|
||||
|
||||
/**
|
||||
* Utility classes
|
||||
*/
|
||||
UserAuthorizationInterface::class => function(ContainerInterface $container) {
|
||||
return new BasicUserAuthorization();
|
||||
},
|
||||
|
||||
/**
|
||||
* Add the Domain Repositories Here
|
||||
*/
|
||||
UserRepositoryInterface::class => function (ContainerInterface $container) {
|
||||
return new UserRepository(
|
||||
$container->get(DatabaseConnectionInterface::class),
|
||||
@ -137,9 +181,8 @@ class Bootstrap
|
||||
$config = $container->get('config');
|
||||
|
||||
// Twig
|
||||
$templatePath = __DIR__ . "/../templates";
|
||||
$templateCache = false;
|
||||
$twig = Twig::create($templatePath, [ 'cache' => $templateCache ]);
|
||||
$twig = Twig::create(APP_LOG_DIR, [ 'cache' => $templateCache ]);
|
||||
|
||||
// Add the global variables
|
||||
$twig->getEnvironment()
|
||||
|
Loading…
Reference in New Issue
Block a user