PHPackages                             publicuhc/php-yggdrasil - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. publicuhc/php-yggdrasil

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

publicuhc/php-yggdrasil
=======================

PHP Library for interacting with Mojang authentication servers

1.0.2(10y ago)426331GPL-3.0+PHP

Since Jun 20Pushed 10y ago2 watchersCompare

[ Source](https://github.com/Eluinhost/php-yggdrasil)[ Packagist](https://packagist.org/packages/publicuhc/php-yggdrasil)[ RSS](/packages/publicuhc-php-yggdrasil/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (3)Dependencies (2)Versions (5)Used By (1)

php-yggdrasil
=============

[](#php-yggdrasil)

[![SensioLabsInsight](https://camo.githubusercontent.com/88b98999fa59edd1d30b61bc3e02ed82f5f8c9d37766914104b7db9e570c3077/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f66366237326134392d323836652d343663362d383262662d3664663331343234643663622f736d616c6c2e706e67)](https://insight.sensiolabs.com/projects/f6b72a49-286e-46c6-82bf-6df31424d6cb)

PHP Library for interacting with Mojang authentication servers.

Installation
------------

[](#installation)

Using composer add it to your requirements section:

```
{
    "require-dev": {
        "publicuhc/php-yggdrasil": "dev-master"
    }
}

```

Usage
-----

[](#usage)

First you need to get hold of a `Yggdrasil` instance, the only choice right now is `DefaultYggdrasil`

```
$yggdrasil = new DefaultYddrasil();

```

You can also pass the username/clientToken/accessToken in the constructor if needed, or alternatively use the setter methods.

You can then use the Yggdrasil instance to query against the server:

```
//set the username
$yggdrasil->setUsername('joe@blogs.com');

//authenticate with the password, sets accessToken/clientToken on success
$yggdrasil->authenticate('joeisthebest');

$clientToken = $yggdrasil->getClientToken();
$accessToken = $yggdrasil->getAccessToken();

```

Error Checking
--------------

[](#error-checking)

All API functions can throw the following:

`APIRequestException`

Thrown when the mojang servers returned errors for the request, the short error can be found at $ex-&gt;getShortMessage(), the full message can get found at $ex-&gt;getMessage(), and the cause (if set) can be found at $ex-&gt;getCause()

`InvalidParameterException`

Thrown when an API method was called and certain parameters were not set yet. e.g.

```
//username not set yet
$yg = new DefaultYggdrasil();

//will throw InvalidParameterException due to username not being set
$yg->authenticate('xxx');

$yg->setUsername('yyy');

//will run correctly
$yg->authenticate('xxx');

```

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~366 days

Total

3

Last Release

3653d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7514501?v=4)[Graham Howden](/maintainers/Eluinhost)[@Eluinhost](https://github.com/Eluinhost)

---

Top Contributors

[![Eluinhost](https://avatars.githubusercontent.com/u/7514501?v=4)](https://github.com/Eluinhost "Eluinhost (55 commits)")

---

Tags

authAuthenticationminecraftMojangyggdrasilauth-server

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/publicuhc-php-yggdrasil/health.svg)

```
[![Health](https://phpackages.com/badges/publicuhc-php-yggdrasil/health.svg)](https://phpackages.com/packages/publicuhc-php-yggdrasil)
```

###  Alternatives

[google/auth

Google Auth Library for PHP

1.4k286.7M205](/packages/google-auth)[kreait/firebase-tokens

A library to work with Firebase tokens

23943.8M18](/packages/kreait-firebase-tokens)[ellaisys/aws-cognito

AWS Cognito package that allows Auth and other related features using the AWS SDK for PHP

121242.9k1](/packages/ellaisys-aws-cognito)[kinde-oss/kinde-auth-php

Kinde PHP SDK for authentication

2280.2k3](/packages/kinde-oss-kinde-auth-php)[casdoor/casdoor-php-sdk

PHP client SDK for Casdoor

2319.8k](/packages/casdoor-casdoor-php-sdk)[awes-io/auth

Laravel Authentication package with built-in two-factor (Authy) and social authentication (Socialite).

3826.7k1](/packages/awes-io-auth)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
