Have searched the net and forums prior to posting this but can’t seem to find an answer.
I see that with PSR-4 autoloading (based on code within Sage/its dependencies) we only need to “use” a namespace to require the file we need.
However, I can’t seem to load my files or even instantiate them.
I can see that in Sage composer.json we have
So, naturally, I have added a file called ‘post-types.php’ inside of ‘app/’ which is a basic class to load other post types. The problem is that nothing in this file is being executed - unless I manually instantiate the class at the end of the file.
var_dump('outside class scope');
public function __construct()
// new Event();
var_dump('inside class constructor');
Neither var_dumps work even though the first is outside of the class scope.
I know I could simply add ‘new PostTypes();’ at the bottom of this file, but surely I should have to do that with the autoloading? Seems to be the case when I look at other classes within vendor/
Can anyone point out what I’m doing wrong here? Feel like it must be something very simple that I’m missing.
Any help appreciated.