PHP code example of technicpack / launcher-api

1. Go to this page and download the library: Download technicpack/launcher-api 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/ */

    

technicpack / launcher-api example snippets


TechnicPack\LauncherApi\Providers\LauncherApiServiceProvider::class,

foreach ($modpack->clients as $client) {
    echo $client->token;
}

if ($modpack->hasClients()) {
    // This modpack has at least one client...
}

if ($modpack->knowsClient($client)) {
    // The modpack knows the given client (the client is attached)...
}

// Get modpacks for which the given client is known...
$modpacks = Modpack::scopeForClient($client)->get();

// Get modpacks for which the given client token is known...
$modpacks = Modpack::scopeForClientToken($token)->get();

// Attach the client to the modpack...
$modpack->attachClient($client);

// Remove the client from the modpack...
$modpack->dettachClient($client);

use TechnicPack\LauncherApi\Build as PlatformBuild;
use TechnicPack\LauncherApi\Modpack as PlatformModpack;

class Modpack implements PlatformModpack
{
    public function builds()
    {
        // Return a hasMany or belongsToMany relationship of your builds model
        // eg: return $this->hasMany(Build::class);
    }

    public function scopePublic(Builder $query)
    {
        // Provide a scope for modpacks which should be public
        // eg: return $query->where('private', false);
    }

    public function scopePrivate(Builder $query)
    {
        // Provide a scope for modpacks which should be private
        // eg: return $query->where('private', true);
    }
}

class Build implements PlatformBuild
{
    public function mods()
    {
        // Return a hasMany or belongsToMany relationship of your Mods model
        // eg: return $this->hasMany(Mod::class);
    }

    public function scopePublic(Builder $query)
    {
        // Provide a scope for builds which should be public
        // eg: return $query->where('private', false);
    }

    public function scopePrivate(Builder $query)
    {
        // Provide a scope for builds which should be private
        // eg: return $query->where('private', true);
    }
}