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 ...
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, ...
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!');
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/...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
autoloading × 3phpunit × 2
unit-testing × 2
php × 1
civicrm-buildkit × 1
civix × 1
best-practice × 1
coding-standards × 1