PHP code example of aternos / codex-minecraft

1. Go to this page and download the library: Download aternos/codex-minecraft library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

aternos / codex-minecraft example snippets




$logFile = new \Aternos\Codex\Log\File\StringLogFile("This is the log content");
$logFile = new \Aternos\Codex\Log\File\PathLogFile("/path/to/log");
$logFile = new \Aternos\Codex\Log\File\StreamLogFile(fopen("/path/to/log", "r"));



$log = new \Aternos\Codex\Minecraft\Log\Minecraft\Vanilla\VanillaServerLog();
$log->setLogFile($logFile);



$detective = new \Aternos\Codex\Minecraft\Detective\Detective();
$detective->setLogFile($logFile);
$log = $detective->detect();



$log->parse();



$analysis = $log->analyse();



foreach ($analysis->getInformation() as $information) {
    echo $information->getLabel() . ": " . $information->getValue();
}

foreach ($analysis->getProblems() as $problem) {
    echo $problem->getMessage();
    foreach($problem->getSolutions() as $solution) {
        echo $solution->getMessage();
    }
}



\Aternos\Codex\Minecraft\Translator\Translator::getInstance()->setLanguage("de");