First Commit

This commit is contained in:
marco
2026-09-04 14:54:13 -03:00
commit 9c54bd3ac7
4914 changed files with 789004 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
<?php
use DI\ContainerBuilder;
use eftec\bladeone\BladeOne;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Twig\Environment;
use Twig\Loader\FilesystemLoader;
use Twig\TwigFunction;
$containerBuilder = new ContainerBuilder();
$containerBuilder->useAutowiring(true); // Enable autowiring
$containerBuilder->addDefinitions([
BladeOne::class => function () {
return new BladeOne(VIEWS_PATH, CACHE_PATH, BladeOne::MODE_AUTO);
},
Logger::class => function () {
$logger = new Logger('app');
$logger->pushHandler(new StreamHandler(__DIR__ . '/../logs/app.log', Logger::DEBUG));
return $logger;
},
Environment::class => function () {
$loader = new FilesystemLoader(VIEWS_PATH);
$twig = new Environment($loader);
// Register the PHP function getCsrfToken
$csrfFunction = new TwigFunction('csrf', function () {
return getCsrfToken();
});
$twig->addFunction($csrfFunction);
return $twig;
}
]);
$container = $containerBuilder->build();
// Make the container globally available
$GLOBALS['container'] = $container;
+24
View File
@@ -0,0 +1,24 @@
<?php
use Illuminate\Database\Capsule\Manager as Capsule;
$capsule = new Capsule;
$capsule->addConnection([
'driver' => $_ENV['DB_CONNECTION'],
'host' => $_ENV['DB_HOST'],
'database' => $_ENV['DB_DATABASE'],
'username' => $_ENV['DB_USERNAME'],
'password' => $_ENV['DB_PASSWORD'],
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
]);
// Set the Capsule as the global manager for Eloquent ORM
$capsule->setAsGlobal();
// Initialize Eloquent ORM
$capsule->bootEloquent();
+45
View File
@@ -0,0 +1,45 @@
<?php
/**
* Loads environment variables from the .env file and defines them as constants.
*
* @param string $path Path to the .env file
*/
function loadEnvToConstants($path) {
if (!file_exists($path)) {
throw new Exception("The .env file was not found at the path: $path");
}
$lines = file($path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($lines as $line) {
// Ignore comments
if (strpos(trim($line), '#') === 0) {
continue;
}
// Split key and value
list($name, $value) = explode('=', $line, 2);
// Remove whitespace
$name = trim($name);
$value = trim($value);
// Check if the value is enclosed in quotes and remove them
if (preg_match('/^"(.*)"$/', $value, $matches)) {
$value = $matches[1];
} elseif (preg_match("/^'(.*)'$/", $value, $matches)) {
$value = $matches[1];
}
// Define as constant
define($name, $value);
}
}
// Using the function
try {
loadEnvToConstants(__DIR__ . '/../.env'); // Adjust the path as necessary
# echo "Environment variables successfully loaded as constants!";
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
+6
View File
@@ -0,0 +1,6 @@
<?php
define('VIEWS_PATH', __DIR__ . '/../resources/views');
define('CACHE_PATH', __DIR__ . '/../cache');
?>
+10
View File
@@ -0,0 +1,10 @@
<?php
function csrfField() {
return '<input type="hidden" name="csrf_token" value="' . getCsrfToken() . '">';
}
function csrf() {
echo csrfField();
}
?>