PHP code example of games647 / minecraft-banner-generator

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

    

games647 / minecraft-banner-generator example snippets


//this is only used if you don't use composer
Banner.php';

use \MinecraftBanner\ServerBanner;
use \MinecraftBanner\MinecraftBanner;

[...]

//tell the browser that we will send the raw image without HTML
header('Content-type: image/png');

$banner = ServerBanner::server("example.minecraft.com", "§aHallo §cWelt");
imagepng($banner);

$favicon = imagecreatefrompng("server_favicon.png");
$image = ServerBanner::server("example.minecraft.com", "§aHallo §cWelt", -1, -1, $favicon, "MinecraftBanner::[DEFAULT_BACKGROUND, CLOUDS_BACKGROUND, LILLY_PADS_BACKGROUND, HILLS_BACKGROUND, WATERFALL_BACKGROUND, CANYON_BACKGROUND, GRASSLAND_BACKGROUND, GRASSLAND_CANYON_BACKGROUND, SWAMP_BACKGROUND, LAKE_BACKGROUND, SWAMP2_BACKGROUND, LILLY_PADS_SWAMP_BACKGROUND]");

$favicon = imagecreatefrompng("server_favicon.png");
$image = ServerBanner::server("example.minecraft.com", "§aHallo §cWelt", -1, -1, $favicon);


$favicon = imagecreatefrompng("notch_head.png");
$image = PlayerBanner::player("Notch", $favicon);

$favicon = imagecreatefrompng("server_favicon.png");
$image = ServerBanner::server("example.minecraft.com", "§aHallo §cWelt", -1, -1, $favicon, MinecraftBanner::LILLY_PADS_BACKGROUND);

$favicon = imagecreatefrompng("notch_head.png");
$image = PlayerBanner::player("Notch", $favicon, MinecraftBanner::LILLY_PADS_BACKGROUND);