I'm trying to execute function in PMMP plugin file from other PHP file. But, Class not found error is outputted at other PHP file. Code is PMMP plugin PHP: <?phpnamespace EasyCHAT;use pocketmine\Player;use pocketmine\plugin\PluginBase;use pocketmine\Server;use pocketmine\event\Listener;use pocketmine\event\player\PlayerChatEvent;use pocketmine\utils\Config;use EasyCHAT\WebSocket;class EasyCHAT extends PluginBase implements Listener{static $Instance;public function onLoad(){ $instance = $this;}public static function getInstance(){ return self::$Instance;}public function onEnable(){ if(!file_exists($this->getDataFolder())){ mkdir($this->getDataFolder(), 0744, true); $this->config = new Config($this->getDataFolder()."Data.json", Config::JSON); $this->config->set("ID", ""); $this->config->save(); } $this->config = new Config($this->getDataFolder()."Data.json", Config::JSON); $this->getServer()->getPluginManager()->registerEvents($this, $this); $this->getLogger()->info("ロード完了");}public function onChat(PlayerChatEvent $event){ $Message = $event->getMessage(); $PlayerName = $event->getPlayer()->getName(); $this->getLogger()->info($Message."+".$PlayerName);}public static function showMessage($mes){ $this->getLogger()->info("メッセージを受信しました: ".$mes);}} other PHP file PHP: <?phpnamespace EasyCHAT;use Ratchet\MessageComponentInterface;use Ratchet\ConnectionInterface;use Ratchet\Server\IoServer;use Ratchet\WebSocket\WsServer;use Ratchet\Http\HttpServer;use EasyCHAT\EasyCHAT;require __DIR__.'/vendor/autoload.php';class WebSocket implements MessageComponentInterface {protected $clients; public function __construct() { $this->clients = new \SplObjectStorage; } public function onOpen(ConnectionInterface $conn) { $this->clients->attach($conn); } public function onMessage(ConnectionInterface $from, $msg) { foreach ($this->clients as $client) { if ($from != $client) { $client->send($msg); } } echo $msg; $send = EasyCHAT::getInstance(); $send->showMessage($msg); } public function onClose(ConnectionInterface $conn) { $this->clients->detach($conn); } public function onError(ConnectionInterface $conn, \Exception $e) { $conn->close(); }}$server = IoServer:: I want to execute "showMessage" function in PMMP plugin file. But, when the "onMessage" function of other PHP file is executed, that error is output to the command prompt executing other PHP file. What should I do?
Are you sure composer initialized the vendor directory in __DIR__? Also note that the PocketMine autoloader is rather rude -- it throws an exception if it cannot load the class. Not sure if this is still true now.
where is your composer.json located? __DIR__ is the namespace folder inside the source folder. I bet it's not the directory your composer.json is located at, or otherwise the vendor/ directory created by composer, right? I believe you can, but you may have to modify composer code a bit to make it prepend autoloaders.