2017 © Pedro Peláez
 

library minecraft-php

A fluent wrapper around Mojang's Minecraft API.

image

sven/minecraft-php

A fluent wrapper around Mojang's Minecraft API.

  • Thursday, May 25, 2017
  • by svenluijten
  • Repository
  • 1 Watchers
  • 1 Stars
  • 175 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Minecraft API

Latest Version on Packagist Total Downloads ![Software License][ico-license], (*1)

This is a simple package providing you with all the tools to quickstart development on that Minecraft site you've been craving. Retrieve UUIDs based on usernames or the other way around with a simple and human-readable API., (*2)

Install

Via composer:, (*3)

$ composer require sven/minecraft-php

If you're using the Laravel framework, you can add the MinecraftServiceProvider to your providers array:, (*4)

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

You may also add the Minecraft facade to the aliases array to use the facade:, (*5)

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

Usage

$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);

If you specified the alias in config/app.php, you can use the facade:, (*6)

Minecraft::fromName($username);

Minecraft::fromUuid($uuid);

This always returns you the same object (Sven\Minecraft\Minecraft). You may use the get() and only($property) methods on it to retrieve the data:, (*7)

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

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

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

If you want more flexibility, the ->get() method returns a JSON object of data for your user:, (*8)

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

Rate limiting

Mojang has some rate limiting in place so you are expected to cache the results. You may send 1 request per minute to the same resource, and you may request as many unique resources as you'd like. Keep in mind Mojang might change this at any time., (*9)

Credits

This is simply a wrapper around Mojang's API, beautifully (yet unofficially) documented at http://wiki.vg/Mojang_API., (*10)

License

sven/minecraft-php is licensed under the MIT License (MIT). Please see the license file for more information., (*11)

The Versions

25/05 2017

dev-master

9999999-dev

A fluent wrapper around Mojang's Minecraft API.

  Sources   Download

MIT

The Requires

 

api minecraft mojang

25/05 2017

v0.0.4

0.0.4.0

A fluent wrapper around Mojang's Minecraft API.

  Sources   Download

MIT

The Requires

 

api minecraft mojang

24/03 2016

v0.0.3

0.0.3.0 https://github.com/svenluijten/minecraft-php

A fluent wrapper around Mojang's Minecraft API.

  Sources   Download

MIT

The Requires

 

api minecraft mojang

22/01 2016

0.0.2

0.0.2.0 https://github.com/svenluijten/minecraft-php

A fluent wrapper around Mojang's Minecraft API.

  Sources   Download

MIT

The Requires

 

api minecraft mojang minecraft php

09/01 2016

0.0.1

0.0.1.0 https://github.com/svenluijten/minecraft-php

A fluent wrapper around Minecraft's API.

  Sources   Download

MIT

The Requires

 

api minecraft mojang