PHP code example of cable8mm / pretty-profile

1. Go to this page and download the library: Download cable8mm/pretty-profile 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/ */

    

cable8mm / pretty-profile example snippets


use Cable8mm\PrettyProfile\PrettyProfile;

// Generate nickname
$nickname = PrettyProfile::getInstance()->nickname(12345);
// Output: "Happy Poodle" (example)

// Get dog image URL
$dogImage = PrettyProfile::getInstance()->dog(12345);
// Output: "https://cabinet-pets.palgle.com/avatars/dog/61.png"

// Get cat image URL (medium size)
$catImage = PrettyProfile::getInstance()->cat(12345, 'medium');
// Output: "https://cabinet-pets.palgle.com/avatars/cat/medium/13.png"

echo PrettyProfile::getInstance()->nickname(1);
//=> Ordinary Nebelung

echo PrettyProfile::getInstance()->nickname(2);
//=> Sexy Norwegian Forest

echo PrettyProfile::getInstance()->cat(1);
//=> https://cabinet-pets.palgle.com/avatars/cat/1.png

echo PrettyProfile::getInstance()->cat(1, 'medium');
//=> https://cabinet-pets.palgle.com/avatars/cat/medium/1.png

echo PrettyProfile::getInstance()->dog(1);
//=> https://cabinet-pets.palgle.com/avatars/dog/1.png

echo PrettyProfile::getInstance()->dog(1, 'large');
//=> https://cabinet-pets.palgle.com/avatars/dog/large/1.png

$cats = PrettyProfile::getInstance()->cats();
// Array of 41 image URLs

$cats = PrettyProfile::getInstance()->cats('medium');
// Array of 41 medium-sized image URLs

$dogs = PrettyProfile::getInstance()->dogs();
// Array of 80 image URLs

$dogs = PrettyProfile::getInstance()->dogs('small');
// Array of 80 small-sized image URLs

echo PrettyProfile::backgroundImage();
//=> https://cabinet-pets.palgle.com/bg/bg-1.png

echo PrettyProfile::backgroundImage('https://example.com/bg.png');
//=> https://example.com/bg.png

use Cable8mm\PrettyProfile\PrettyProfile;

$userId = 393939;

// Generate nickname
$nickname = PrettyProfile::getInstance()->nickname($userId);
echo $nickname; // "Ordinary Nebelung"

// Get dog profile image
$dogImage = PrettyProfile::getInstance()->dog($userId);
echo $dogImage; // "https://cabinet-pets.palgle.com/avatars/dog/64.png"

// Get cat profile image (medium size)
$catImage = PrettyProfile::getInstance()->cat($userId, 'medium');
echo $catImage; // "https://cabinet-pets.palgle.com/avatars/cat/medium/10.png"

use Cable8mm\PrettyProfile\PrettyProfile;

// Get all dog images (original size)
$allDogs = PrettyProfile::getInstance()->dogs();

// Get all cat images (medium size)
$allCatsMedium = PrettyProfile::getInstance()->cats('medium');

// Generate preview
foreach ($allDogs as $index => $url) {
    echo "![Dog $index]($url)\n";
}

use Cable8mm\PrettyProfile\PrettyProfile;

try {
    // Invalid ID (0 or negative)
    PrettyProfile::getInstance()->cat(0);
} catch (\InvalidArgumentException $e) {
    echo $e->getMessage();
    // "The value must be over 0, so a value of 0 is not valid."
}

try {
    // Invalid size
    PrettyProfile::getInstance()->dog(1, 'huge');
} catch (\InvalidArgumentException $e) {
    echo $e->getMessage();
    // "The value must be "large" or "medium" or "small", so a value of "huge" is not valid."
}

try {
    // Invalid animal
    PrettyProfile::profileImage(1, animal: 'rabbit');
} catch (\InvalidArgumentException $e) {
    echo $e->getMessage();
    // "The value must be dog or cat. rabbit is not valid."
}

// Example: Dog images (80 total)
$id = 827342;
$imageNumber = ($id - 1) % 80 + 1; // 62
// User #827342 always uses image #62

// Example: ID 1
$prefixIndex = (1 - 1) % 40; // 0 → First adjective
$nicknameIndex = (1 - 1) % 66; // 0 → First breed name
// Result: "Ordinary Nebelung" (example)
bash
php artisan vendor:publish --tag=pretty-profile-config
blade
{{-- Basic usage --}}
<img src="{{ PrettyProfile::profileImage($user->id, animal: 'dog') }}" alt="Profile">

{{-- Cat image --}}
<img src="{{ PrettyProfile::profileImage($user->id, animal: 'cat') }}" alt="Profile">

{{-- Custom image (takes priority) --}}
<img src="{{ PrettyProfile::profileImage($user->id, image: $user->custom_avatar) }}" alt="Profile">