PHP code example of sven / minecraft-php

1. Go to this page and download the library: Download sven/minecraft-php 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/ */

    

sven / minecraft-php example snippets


// config/app.php
'providers' => [
    ...
    Sven\Minecraft\MinecraftServiceProvider::class,
    ...
];

// config/app.php
'aliases' => [
    ...
    'Minecraft' => Sven\Minecraft\Facades\Minecraft::class,
    ...
];

$minecraft = new Sven\Minecraft\Minecraft;

// Build up the user object from a given username.
$minecraft->fromName($username);

// Supply an optional UNIX timestamp to get the user object of the player who
// owned that username at the time.
$minecraft->fromName($username, time() - (365 * 24 * 60 * 60));

// Build up the user object from a given UUID.
$minecraft->fromUuid($uuid);

Minecraft::fromName($username);

Minecraft::fromUuid($uuid);

$minecraft = new Minecraft;
$user = $minecraft->fromName('jeb_');

$user->get()->name;  // jeb_
$user->get()->uuid;  // 853c80ef3c3749fdaa49938b674adae6

$user->only('name'); // jeb_
$user->only('uuid'); // 853c80ef3c3749fdaa49938b674adae6

$user->get(); // {"name": "jeb_", "uuid": "853c80ef3c3749fdaa49938b674adae6"}
bash
$ composer