5 votes
Accepted

Class naming and namespaces: best practice as an extension author?

The conventional approach Generally, the safe play is to make a file like <myextension>/CRM/MyExtension/MyClass.php: <?php class CRM_MyExtension_MyClass { ...} (Be sure to match the ...
user avatar
  • 5,564
4 votes

Does class autoloading not work in standalone phpunit testing?

This is an issue with intermediate base-classes for tests (like VolunteerTestAbstract). The most reliable solution I've found is to put a require_once to load the intermediate base-class. For example, ...
user avatar
  • 5,564
2 votes

class Civi not found

Ok, so it turns out I was kinda doing something wrong... What I needed was a simple \ prefix: \Civi::log()->info('Hello, log!');
user avatar
  • 1,561
2 votes
Accepted

Does class autoloading not work in standalone phpunit testing?

Civi's autoloader does not load classes outside the CRM directory. In order for that to work, you'll have a few options: Implement your own autoloader capable of loading classes inside the test/...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible