[Error] Class 'Has \ Module \ CompanyPoints' not found (0)

<? namespace Has\Module; use \Bitrix\Main\Config\Option; use \Bitrix\Main\UserTable as User; class CompanyPoints{ function func(){return true;} } ?> 

test.php

  use \Bitrix\Main\Loader; use \Bitrix\Main\Application; use \Has\Module\CompanyPoints; Loader::includeModule("Module"); $addresses=CompanyPoints::func(); 

An error comes out, why?

  • 2
    Avtoloader not aware of these neymspeysy? - u_mulder
  • First, I did not find the autoloader either in the locale folder or in the bitrix folder. But, if you turn to another class's method of another file, everything works - Rabin
  • @u_mulder, if you refer to the method of another class of another file, then everything works) if I rename the file of another class, then the other class stops working ... So, where is the autoloader, and where I can not find it - Rabin
  • one
    The autoloader is in the include.php file in each module. - u_mulder

1 answer 1

If this is your module, then you need to load your library into include. Or in init.php

  CModule::AddAutoloadClasses( '', // не указываем имя модуля array( // ключ - имя класса, значение - путь относительно корня сайта к файлу с классом 'CMyClassName1' => '/path/cmyclassname1file.php', 'CMyClassName2' => '/path/cmyclassname2file.php', ) );