Files
dockersysmvc/config/container.php
T
marco 5a2482b030 feat: release SysMVC 2.0 with enhanced CSRF protection and UI improvements
Major version upgrade from 1.0.0 to 2.0.0 including copyright year updates, website URL migration to syspanel.com.br, and comprehensive CSRF token handling improvements. The Twig csrf() helper now returns a complete hidden input field instead of a raw token value, and token generation is now automatic when empty. Session initialization has been centralized in BaseController, and child controllers now properly call parent constructors. CRUD views have been modernized with flexbox layouts and consistent CSRF rendering. Documentation has been expanded with features, requirements, and project structure sections, and donation sections have been added across all pages.
2026-09-04 15:43:17 -03:00

48 lines
1.3 KiB
PHP
Executable File

<?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 csrf helper — returns a hidden input field (same as Blade's csrf())
$csrfFunction = new TwigFunction('csrf', function () {
return '<input type="hidden" name="csrf_token" value="' . htmlspecialchars(getCsrfToken(), ENT_QUOTES, 'UTF-8') . '">';
});
$twig->addFunction($csrfFunction);
return $twig;
}
]);
$container = $containerBuilder->build();
// Make the container globally available
$GLOBALS['container'] = $container;