1. Go to this page and download the library: Download squirrelphp/twig-php-syntax 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/ */
squirrelphp / twig-php-syntax example snippets
$twig = new \Twig\Environment($loader);
$twig->addExtension(new \Squirrel\TwigPhpSyntax\PhpSyntaxExtension());
twig
{% foreach list as sublist %}
{% foreach sublist as key => value %}
{% endforeach %}
{% endforeach %}
twig
{% foreach list as sublist %}
{% foreach sublist as entry %}
{% if loop.index > 10 %}
{% break 2 %} {# breaks out of both foreach loops #}
{% endif %}
{% endforeach %}
{% endforeach %}
twig
{% if someflag === true && otherflag === false %}
instead of if someflag === true and otherflag === false
{% endif %}
{% if someflag === true || otherflag === true %}
instead of if someflag === true or otherflag === false
{% endif %}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.