'The router path problem [DannyVankooten php router class]

I try to do something for 2 days and i can't...

I have a extensions for my system, which is made with event dispatcher. The system is working with php 7.4 well, but i don't know what to do to make a proper path for a controler for my router...

Here is some code:

BaseController:

<?php
namespace App\Controllers;
    
class BaseController {
    
  public function __construct() {
         $checker = $dbh->query('SELECT ext_name FROM '.getenv("DB_PREFIX").'ext WHERE ext_active=1');    
  if($checker->rowCount() > 0) {
    while($row=$checker->fetch(PDO::FETCH_ASSOC)){
      $ext_name = $row['ext_name'];
      if(file_exists(__DIR__.'/../ext/'.$ext_name.'/ext.php')) {
        require_once(__DIR__.'/../ext/'.$ext_name.'/ext.php');
      }
    }
  }
}
};

Router:

$collection->attachRoute(new PHPRouter\Route('/ajax/ext/:id', [
       '_controller' => 'ext\pok4\the_tickets::ajax',
       'methods' => ['POST','GET'],
       'parameters'=> ['template_file'=>'ajax'],
]));

And part of extension:

<?php 
class the_tickets extends \App\Controllers\BaseController  {
                  
    public function __construct() {
       parent::__construct(); 
    }
                  
                
    public function ajax() {
        echo 1;          
    }
};
$load_ext = new the_tickets;
$load_ext->load();

the extensions is called by a basecontroller __construct and i dont know which controller path to put in the router.... The path of the extension is: C:\xampp\htdocs\ext\pok4\the_tickets

Now i get this: Fatal error: Uncaught Error: Class 'ext\pok4\the_tickets' not found in C:\xampp\htdocs\vendor\dannyvankooten\php-router\src\Route.php:199 Stack trace: #0

the path in the router for controller is this: '_controller' => 'ext\pok4\the_tickets::ajax',

You can see this above in the examples which i give...

What to do ? Please, this is very important for me to make ajax calls from this 'small' modules which is call'd 'extensions'. They are separate from the system and can be enabled or disabled. They are small classes.

Thank you for any help.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source