MainClass.php: PHP: <?phpnamespace myplugin;use pocketmine\plugin\PluginBase;class MainClass extends PluginBase { public function onEnable() { $foo = new SecondClass(); $foo->doStuff(); $bar = new ThirdClass(); $bar->moreStuff(); } public function test() { // do stuff }} SecondClass.php: PHP: <?phpnamespace myplugin;class SecondClass { public function doStuff() { // do stuff }} ThirdClass.php: PHP: <?phpnamespace myplugin;class ThirdClass { public function moreStuff() { // do stuff }} All of these files should be in the same folder and the plugin.yml should only point to MainClass.
According to PSR-0 and pocketmine documentation, class name MUST be identical to file name, excluding extension '.php' and namespace MUST be path relative to `src` folder. With that said, PocketMine will automatically load every class inside `src` folder and they can be accessed using the namespaces and imported using the `use` statements. Got it? An example: I've created a Foo.php inside src\bar folder and set the namespace to `bar` and now whenever I want to reference that class in any other file, I do it with namespace like this PHP: $foo = new bar\Foo(); or PHP: use bar\Foo;$foo = new Foo(); It's stupid that we have to repeat this over and over again. What makes you think that posting here will be more efficient? I haven't posted here anything related to my issues with PocketMine because most of them involve common sense and simple debugging techniques to resolve them or googling around to read about something new, like in your case this, so let me google that for you
How the hell would he know to type PSR-0 into google? I've been doing PHP for four years and I've never even heard of that.
No, you don't need to. Yes, of course it works. PSR-0 is a code style. It suggest how to make clean and readable code.
I've been doing PHP for almost a year (actually, "coding" for almost a year) and don't think PSR is a needed information to create a sub class :3
No, oft it is not needed to create a subclass. It is needed to create style conform code or contribute to pmmp. It will also help you reading your code later.