PHP code example of maduser / argon-twig

1. Go to this page and download the library: Download maduser/argon-twig library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

maduser / argon-twig example snippets


use Maduser\Argon\Twig\Provider\TwigServiceProvider;

$container->register(TwigServiceProvider::class);

$container->getParameters()->set('basePath', dirname(__DIR__));

use Maduser\Argon\Twig\Config\TwigParameter;

$container->getParameters()->set(TwigParameter::DEFAULT_PATH, __DIR__ . '/../templates');

use Maduser\Argon\Container\AbstractServiceProvider;
use Maduser\Argon\Container\ArgonContainer;
use Maduser\Argon\Twig\TemplatePathRegistry;

final class AuthServiceProvider extends AbstractServiceProvider
{
    #[\Override]
    public function register(ArgonContainer $container): void
    {
        $registry = $container->get(TemplatePathRegistry::class);

        $registry->addPath(__DIR__ . '/resources/templates', 'auth');
    }
}

$html = $twig->render('@auth/login.html.twig');

use Maduser\Argon\Twig\Config\TwigParameter;

$parameters = $container->getParameters();
$parameters->set(TwigParameter::DEBUG, true);
$parameters->set(TwigParameter::AUTO_RELOAD, true);
$parameters->set(TwigParameter::STRICT_VARIABLES, true);
$parameters->set(TwigParameter::CACHE, dirname(__DIR__) . '/storage/cache/twig');