How do I run PHP code when visiting a specific URL?
Apart from controllers, one could also listen for Events,  using code similar to the following. Depending on what the custom logic mentioned in the OP is expected to do, this could be an alternative answer.

nncbt.services.yml:

services:
  nncbt_event_subscriber:
    class: '\Drupal\nncbt\EventSubscriber\NNCBTSubscriber'
    arguments:
      - '@logger.factory'
    tags:
      - { name: 'event_subscriber' }


src/EventSubscriber/NNCBTSubscriber.php:

&lt;?php

namespace Drupal\nncbt\EventSubscriber;

use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\PostResponseEvent;
use Drupal\Core\Logger\LoggerChannelFactory;

/**
 * An EventSubscriber for REQUEST and TERMINATE events.
 */
class NNCBTSubscriber implements EventSubscriberInterface {

  /**
   * The logger.
   *
   * @var \Drupal\Core\Logger\LoggerChannelInterface
   */
  protected $logger;

  /**
   * Constructor.
   *
   * @param \Drupal\Core\Logger\LoggerChannelFactory $logger_channel_factory
   *   For logging purposes.
   */
  public function __construct(LoggerChannelFactory $logger_channel_factory) {
    $this-&gt;logger = $logger_channel_factory-&gt;get(self::class);
  }

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    $events[KernelEvents::REQUEST][] = ['earlyCode'];
    $events[KernelEvents::TERMINATE][] = ['lateCode'];
    return $events;
  }

  /**
   * This method is called for KernelEvents::REQUEST events.
   *
   * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
   *   The incoming event.
   */
  public function earlyCode(GetResponseEvent $event) {
    $uri = $event-&gt;getRequest()-&gt;getRequestUri();
    $this-&gt;logger-&gt;info($uri);
  }

  /**
   * This method is called for KernelEvents::TERMINATE events.
   *
   * @param \Symfony\Component\HttpKernel\Event\PostResponseEvent $event
   *   The incoming event.
   */
  public function lateCode(PostResponseEvent $event) {
    $uri = $event-&gt;getRequest()-&gt;getRequestUri();
    $this-&gt;logger-&gt;info($uri);
  }

}


Good luck!