Created
November 6, 2012 10:31
-
-
Save serapheem/4023920 to your computer and use it in GitHub Desktop.
Symfony2 - Global Template Variables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List: | |
app.security - The security context. | |
app.user - The current user object. | |
app.request - The request object. | |
app.session - The session object. | |
app.environment - The current environment (dev, prod, etc). | |
app.debug - True if in debug mode. False otherwise. | |
Twig: | |
<p>Username: {{ app.user.username }}</p> | |
{% if app.debug %} | |
<p>Request method: {{ app.request.method }}</p> | |
<p>Application Environment: {{ app.environment }}</p> | |
{% endif %} | |
PHP: | |
<p>Username: <?php echo $app->getUser()->getUsername() ?></p> | |
<?php if ($app->getDebug()): ?> | |
<p>Request method: <?php echo $app->getRequest()->getMethod() ?></p> | |
<p>Application Environment: <?php echo $app->getEnvironment() ?></p> | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment