I keep getting the error Class games\Spleef not found and I'm assuming it has to do with my usage of namespaces, which I'm terrible with. Here's my hierarchy of folders and files: Minigames: src: minigames: Main.php Timer.php BaseGame.php games: Spleef.php Main.php: PHP: namespace minigames;use games\Spleef; //I think this is wrong, not sure thoughclass Main extends PluginBase implements Listener {//blah blah blah} Spleef.php PHP: namespace games;class Spleef implements BaseGame, Listener {//blah blah blah} Any help would be much appreciated
I changed Main.php to PHP: use minigames\games\Spleef; and Spleef.php to PHP: namespace minigames\games; and it worked
In namespace and use statements, you always include the FULLY QUALIFIED name of the class/function/constant without a leading `\`. In normal code references, to include fully qualified name, the class name must start with a `\`. Otherwise, the class name will be assumed as relative (like relative file paths). Of course, if you are in root/global namespace, the `\` doesn't matter.