Path_for null Error

<?php

  require __DIR__.'/../vendor/autoload.php';
  require 'config.php';

  session_start();

  $app = new \Slim\App([
      'settings' => [
          'displayErrorDetails' => false
      ]
      ]);

  $container = $app->getContainer();

  $container['auth'] = function ($container) {
      return new \App\Auth\Auth;
  };

  $container['flash'] = function ($container) {
      return new \Slim\Flash\Messages;
  };

  $container['view'] = function ($container) {
      $view = new \Slim\Views\Twig(__DIR__ .'/../resourses/views', [
          'cache' => false,
      ]);

     $view->getEnvironment()->addGlobal('flash', $container->flash);

      $view->addExtension(new Slim\Views\TwigExtension(
          $container->router,
          $container->request->getUri()
      ));

      return $view;
  };


  require __DIR__. '/../routes/web.php';


when call

return $response->withRedirect($this->router->pathFor('login'));

Undefined property: App\Controllers\AuthController::$router

What does your AuthController look like? It appears you haven’t assigned the router property to your AuthController class.

Try:

return $response->withRedirect($this->container->get('router')->pathFor('login'));