title: Error Message: Call to a member function render() on null
body: <p>actually I am trying to call my twig file from my controller and here is my code :<br>
   <strong>This is my App.php</strong></p>
  
  <pre><code>&lt;?php
  
  use Slim\App;
  use Slim\Http\Environment;
  use Slim\Http\Uri;
  use Slim\Views\Twig;
  use Slim\Views\TwigExtension;
  
  $app = new App (['settings' =&gt; ['displayErrorDetails' =&gt; true,],]);
  $container = $app-&gt;getContainer();
  $container['view'] = function ($container) {
      $view = new Twig('../Resources/Views/Users', ['cache' =&gt; false]); // Instantiate and add Slim specific extension$router = $container-&gt;get('router');$uri = Uri::createFromEnvironment(new Environment($_SERVER));$view-&gt;addExtension(new TwigExtension($router, $uri));return $view;};require __DIR__ . '/../Routes/routes.php';
  };
  </code></pre>
  
  <p><strong>This is routes.php:-</strong></p>
  
  <pre><code>&lt;?php
  $app-&gt;group('/profile', function () {
      $this-&gt;get('/fetchMyLiveAds', Application\Controllers\COlxMyAdsController::class . ':fetchMyLiveAdIdsByUserId');
      $this-&gt;get('/fetchMyDeniedAds/{id}', Application\Controllers\COlxMyAdsController::class . ':fetchMyDeniedAdIdsByUserId');
      $this-&gt;get('/fetchMyPendingAds/{id}', Application\Controllers\COlxMyAdsController::class . ':fetchMyPendingAdIdsByUserId');
  });
  
  </code></pre>
  
  <p><strong>This is my COlxDatabaseHandler :-</strong>
  You solved My Problem but now when i call fetchMyLiveAds() with the object of COlcUserDetails that is $this->m_objOlxUserDetails now it shows me error that call fetchMyLiveAds() on Null.</p>
  
  <pre><code>&lt;?php
  namespace Application\Eos;
  use Psr\Container\ContainerInterface;
  
  class COlxDatabaseHandler extends Container{
  
      public function __construct( ContainerInterface $c ) {
  
          $this-&gt;m_objOlxCategories      = new COlxCategories( $c );
          $this-&gt;m_objOlxProductImages   = new COlxProductImages( $c );
          $this-&gt;m_objOlxProducts        = new COlxProducts( $c );
          $this-&gt;m_objOlxProductStatuses = new COlxProductStatuses( $c );
          $this-&gt;m_objOlxStatuses        = new COlxStatuses( $c );
          $this-&gt;m_objOlxUserInterests   = new COlxUserInterests( $c );
          $this-&gt;m_objOlxUserLikes       = new COlxUserLikes( $c );
          $this-&gt;m_objOlxUserPurchases   = new COlxUserPurchases( $c );
          $this-&gt;m_objOlxUserDetails     = new COlxUserDetails( $c );
      }
  }
  ?&gt;
  </code></pre>
  
  <p>this is COlxMyAdsController class:</p>
  
  <pre><code>COlxMyAdsController extends COlxDatabaseHandler {
      public
      function fetchMyLiveAdIdsByUserId(Request $request, Response $response)
      {
          $args = $request-&gt;getParams();
          $args = $args['id'];
          $result = count($this-&gt;m_objOlxUserDetails-&gt;fetchMyLiveAdIdsByUserId($args));
          // Here the result stores int(3)
             return $view-&gt;render($response,'profile.twig',['counts'=&gt; $result]);
             or return $this-&gt;view-&gt;render($response,'profile.twig',['counts'=&gt; $result]);
      }
  }
  </code></pre>
  
  <p><strong>this is profile.twig :</strong></p>
  
  <pre><code>&lt;div class="CSlider" &gt;&lt;div class="CProducts" &gt;&lt;table &gt;&lt;tr &gt;{
      %
      for count in 1. . counts %}&lt;td &gt;{
      %
      block tile %}{
      %
      include 'tile.twig' %}{
      %
      endblock %}&lt;/td &gt;{
      %
      if count is divisible by(6) %}&lt;/tr &gt;&lt;tr &gt;{
      % endif %
  }{
      % endfor %
  }&lt;/table &gt;&lt;/div &gt;&lt;/div &gt;
  </code></pre>
  
  <p><strong>And this is div where i want use that result</strong></p>