PHPackages                             richard4339/destiny2-php - 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. [API Development](/categories/api)
4. /
5. richard4339/destiny2-php

ActiveLibrary[API Development](/categories/api)

richard4339/destiny2-php
========================

PHP wrapper for the Destiny 2 API

v0.3.1(6y ago)51.2k2[2 issues](https://github.com/richard4339/destiny2-php/issues)MITPHPPHP &gt;=7.1

Since Sep 25Pushed 6y ago1 watchersCompare

[ Source](https://github.com/richard4339/destiny2-php)[ Packagist](https://packagist.org/packages/richard4339/destiny2-php)[ RSS](/packages/richard4339-destiny2-php/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (3)Dependencies (4)Versions (23)Used By (0)

destiny2-php
============

[](#destiny2-php)

A PHP wrapper for the [Destiny 2 API](https://github.com/Bungie-net/api)

[![Latest Stable Version](https://camo.githubusercontent.com/d91a275badee22646665c6d9298a6e5d5561ca6808545d48ff380f415c080695/68747470733a2f2f706f7365722e707567782e6f72672f72696368617264343333392f64657374696e79322d7068702f762f737461626c65)](https://packagist.org/packages/richard4339/destiny2-php)[![Total Downloads](https://camo.githubusercontent.com/3b1f22a98c41dba94ade08f638cc4fc577bd65ba6698ca3277765f86b0a3387f/68747470733a2f2f706f7365722e707567782e6f72672f72696368617264343333392f64657374696e79322d7068702f646f776e6c6f616473)](https://packagist.org/packages/richard4339/destiny2-php)[![Latest Unstable Version](https://camo.githubusercontent.com/e85545736995a3432f44bf702e7e2e16531ca06a8412d3ba115526e363a831f4/68747470733a2f2f706f7365722e707567782e6f72672f72696368617264343333392f64657374696e79322d7068702f762f756e737461626c65)](https://packagist.org/packages/richard4339/destiny2-php)[![License](https://camo.githubusercontent.com/f557669468ba9964b73cf94a0148648108a1114c2d9b8c5656fe370f8b76ee75/68747470733a2f2f706f7365722e707567782e6f72672f72696368617264343333392f64657374696e79322d7068702f6c6963656e7365)](https://packagist.org/packages/richard4339/destiny2-php)[![composer.lock](https://camo.githubusercontent.com/4739bb9f1b3d9b4415c3ad37d7c86e9a64c6751837bc76c9c49c3339e199b22a/68747470733a2f2f706f7365722e707567782e6f72672f72696368617264343333392f64657374696e79322d7068702f636f6d706f7365726c6f636b)](https://packagist.org/packages/richard4339/destiny2-php)[![Build Status](https://camo.githubusercontent.com/8530a69507a3865916ad674062facd063068e18878166bb64edd83bbf3bae520/68747470733a2f2f7472617669732d63692e6f72672f72696368617264343333392f64657374696e79322d7068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/richard4339/destiny2-php)

About
-----

[](#about)

Currently includes (mostly) just the clan endpoints, with some user endpoints. Basic vendor support has been added as well (Xur's hash is `2190858386` FYI). The goal is to eventually have all endpoints available.

My intention is to make all object calls be JSON Serializable by implementing JsonSerializable()

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

[](#installation)

### Using Composer

[](#using-composer)

```
composer require richard4339/destiny2-php

```

### Upgrading

[](#upgrading)

#### To 0.3

[](#to-03)

- `ClanApproveMember()` method now returns an object instead of a boolean. Any calls to this method that check for a boolean must change.
- `ClanKickMember()` method now returns a boolean for success instead of the abstracted Guzzle response.

Usage
-----

[](#usage)

```
require 'vendor/autoload.php';

$client = new \Destiny\Client('[YOUR API KEY]', '[OPTIONAL OAUTH TOKEN]', '[OPTIONAL CLIENT ID]', '[OPTIONAL CLIENT SECRET]', '[OPTIONAL YOUR APP NAME]', '[OPTIONAL YOUR APP VERSION]', '[OPTIONAL YOUR APP ID]', '[OPTIONAL YOUR APP URL]', '[OPTIONAL YOUR APP EMAIL]');

$clan = $client->getGroup(12345);

try {
    $whoami = $client->getBungieUser(9999999999);
} catch (\Destiny\Exceptions\ClientException $x) {

}

$members = $client->getClanAdminsAndFounder(12345);

```

The optional App Name, Version, ID, URL, and Email fields were added to populate the User-Agent in the header, [which is now recommended by Bungie (and may eventually be required)](https://github.com/Bungie-net/api#are-there-any-restrictions-on-the-api).

### Symfony

[](#symfony)

If you want to use this in a Symfony project, the code below can be used to wire the service in `services.yaml` for calls that do not require OAuth:

```
services:
    Destiny\Client:
        arguments:
            $apiKey: '%destiny.api_key%'
            $appName: '[YOUR APP NAME]'
            $appVersion: '[YOUR APP VERSION]'
            $appIDNumber: '[YOUR APP ID]'
            $appURL: '[YOUR APP URL]'
            $appEmail: '[YOUR EMAIL]'

```

Replace `[YOUR APP NAME]`, `[YOUR APP VERSION]`, `[YOUR APP ID]`, `[YOUR APP URL]`, and `[YOUR EMAIL]`.

It also assumes you have defined your API key defined in your `services.yaml` as well:

```
parameters:
    destiny.client_id: '%env(DESTINY_CLIENT_ID)%'
    destiny.client_secret: '%env(DESTINY_CLIENT_SECRET)%'
    destiny.api_key: '%env(DESTINY_API_KEY)%'

```

For calls that require OAuth, you need to extend `Client` and wire your token in. The code below is just an example that works using the Security component which can get the token from the User.

```
