Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

Autoload a class

+1 vote
101 views
asked Feb 23 in Q2A Core by anonymous

I added this folder to qa-include/Q2A/Events

And inside the Events folder, I added a class file called Amplitude.php and has the class 

class Q2A_Events_Amplitude but it's not autoloaded. Can anyone tell me why? 

Thanks

commented Feb 23 by pupi1985
What Q2A version are you using?

1 Answer

0 votes
answered Mar 1 by Scott
Not sure why that wouldn't work. I just tried it myself (did exactly what you said) and it worked fine. You said "it's not autoloaded" but you didn't say exactly what happened. Did you get an error? What code did you use to call the class?

As a side note, if you're writing your own customizations you shouldn't add your own classes to the core Q2A namespace. If you're writing a plugin your should keep your code within the plugin folder.

Having said that, currently there isn't a standard way to autoload custom classes yet. You could write your own autoloader similar to the Q2A core one (at the top of qa-base.php).

Welcome to the Q&A site for Question2Answer.

If you have a question about Q2A, please ask in English.

To report a bug, please create a new issue on Github or ask a question here with the bug tag.

If you just want to try Q2A, please use the demo site.

Dec 1, 2018: Q2A 1.8.1 released!

...