title: PHP Uncaught exception: 'Twig_Error_Syntax' Message: 'Unknown "asset" function.'
body: <p>I'm using MVC in php and i'm trying to use twig as templating engine. I'm trying to use asset for including css. But i'm facing some errors. It doesnot recognize assest function.</p>
  
  <p>I have used following code:</p>
  
  <p>My core base:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta charset="UTF-8"&gt;
  
      &lt;title&gt;{% block title %}{% endblock %} &lt;/title&gt;
      &lt;!-- &lt;link href="../../vendor/style.css" rel="stylesheet"&gt; --&gt;
  
         &lt;link href="{{ asset('../../vendor/style.css') }}" type="text/css" rel="stylesheet" /&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
    &lt;nav&gt;
      &lt;a href="/"&gt;Home&lt;/a&gt;
      &lt;a href="/posts/index"&gt;Posts&lt;/a&gt;
    &lt;/nav&gt;
    {% block body %}
    {% endblock %}
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Following is the view that extends the base template, dashboard:</p>
  
  <pre><code>{% extends "base.html" %}
  
  {% block title %}Dashboard{% endblock %}
  
  {% block body %}
  
      &lt;h1&gt;Welcome User!&lt;/h1&gt;
      &lt;a href="logout"&gt;&lt;button&gt;Logout&lt;/button&gt;&lt;/a&gt;
  
  {% endblock %}
  </code></pre>
  
  <p>But i'm getting following error:</p>
  
  <pre><code>Uncaught exception: 'Twig_Error_Syntax'
  
  Message: 'Unknown "asset" function.'
  </code></pre>
  
  <p>Full stack trace of the error is below:
  Stack trace:</p>
  
  <pre><code>#0 C:\xampp\app\mvc\vendor\twig\twig\lib\Twig\ExpressionParser.php(364): Twig_ExpressionParser-&gt;getFunctionNodeClass('asset', 9)
  #1 C:\xampp\app\mvc\vendor\twig\twig\lib\Twig\ExpressionParser.php(152): Twig_ExpressionParser-&gt;getFunctionNode('asset', 9)
  #2 C:\xampp\app\mvc\vendor\twig\twig\lib\Twig\ExpressionParser.php(92): Twig_ExpressionParser-&gt;parsePrimaryExpression()
  #3 C:\xampp\app\mvc\vendor\twig\twig\lib\Twig\ExpressionParser.php(45): Twig_ExpressionParser-&gt;getPrimary()
  #4 C:\xampp\app\mvc\vendor\twig\twig\lib\Twig\Parser.php(123): Twig_ExpressionParser-&gt;parseExpression()
  #5 C:\xampp\app\mvc\vendor\twig\twig\lib\Twig\Parser.php(79): Twig_Parser-&gt;subparse(NULL, false)
  #6 C:\xampp\app\mvc\vendor\twig\twig\lib\Twig\Environment.php(512): Twig_Parser-&gt;parse(Object(Twig_TokenStream))
  #7 C:\xampp\app\mvc\vendor\twig\twig\lib\Twig\Environment.php(544): Twig_Environment-&gt;parse(Object(Twig_TokenStream))
  #8 C:\xampp\app\mvc\vendor\twig\twig\lib\Twig\Environment.php(363): Twig_Environment-&gt;compileSource(Object(Twig_Source))
  #9 C:\xampp\app\mvc\vendor\twig\twig\lib\Twig\Template.php(329): Twig_Environment-&gt;loadTemplate('base.html', NULL)
  #10 C:\xampp\app\mvc\vendor\twig\twig\lib\Twig\Environment.php(373) : eval()'d code(11): Twig_Template-&gt;loadTemplate('base.html', 'User/dashboard....', 1)
  #11 C:\xampp\app\mvc\vendor\twig\twig\lib\Twig\Environment.php(385): __TwigTemplate_6a4c151f517970c46aab3eedfdfea56b57d9fb29e4119bece3b41b9de1f71014-&gt;__construct(Object(Twig_Environment))
  #12 C:\xampp\app\mvc\vendor\twig\twig\lib\Twig\Environment.php(288): Twig_Environment-&gt;loadTemplate('User/dashboard....')
  #13 C:\xampp\app\mvc\Core\View.php(35): Twig_Environment-&gt;render('User/dashboard....', Array)
  #14 C:\xampp\app\mvc\App\Controllers\User.php(22): Core\View::renderTemplate('User/dashboard....')
  #15 [internal function]: App\Controllers\User-&gt;loginAction()
  #16 C:\xampp\app\mvc\Core\Controller.php(25): call_user_func_array(Array, Array)
  #17 C:\xampp\app\mvc\Core\Router.php(100): Core\Controller-&gt;__call('login', Array)
  #18 C:\xampp\app\mvc\public\index.php(57): Core\Router-&gt;dispatch('user/login'
  </code></pre>
  
  <p>I don't know what to do now. Can anyone help me? How can i use assest or are there any alternative wy to include my css and js.</p>