I am making this new plugin and long story short it needs to be able to uncompress files. I found how to do that with PHP, but for some reason I can't use it in a PocketMine plugin. Here is the de-compressing code I am using: PHP: $zip = new ZipArchive; $res = $zip->open("foo.zip"); if ($res === TRUE) { $zip->extractTo("../bar"); $zip->close(); unlink("foo.zip"); $sender->sendMessage("Foo has been installed successfully!"); } else { $sender->sendMessage("Foo has failed to install!"); } And here is the error: Code: 2016-11-21 [12:08:43] [Server thread/CRITICAL]: ClassNotFoundException: "Class HittmanA\pmpm\ZipArchive not found" (EXCEPTION) in "/src/spl/BaseClassLoader" at line 144 (Line 144 would be the PHP: $zip = new ZipArchive; line) How can I use ZipArchive in PocketMine?
add a backslash before the class name , like: PHP: $zip = new \ZipArchive(); and should work. if not , you need the PECL zip
ZipArchive is a native PHP class, not one that I made myself so do I need to include the \ or \HittmanA\pmpm\ZipArchive. Also the plugin name is pmpm.
The backslash is because the class is in the root namespace. If you don't add a backslash, PHP will understand it that the class is in your current namespace. Alternatively, you can add a use statement just like other classes: PHP: use ZipArchive;
Native/builtin classes have no necessary relationship with using the top namespace. Where is the votedown button?
I can still qualify \my\clazz\names\like\this instead of using class aliases. And I like to import top namespaces so that I don't need to type the backslash all the time. There is no relationship between the namespace and whether I should fully qualify the class with a leading backslash or use a use statement.