PHP code example of black-sheep-tech / laravel-ui-avatars

1. Go to this page and download the library: Download black-sheep-tech/laravel-ui-avatars 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/ */

    

black-sheep-tech / laravel-ui-avatars example snippets


use BlackSheepTech\UiAvatars\UiAvatars;

$avatarUrl = UiAvatars::make()
    ->name('John Doe')
    ->size(128)
    ->background('#ffffff')
    ->color('#000000')->getUrl();


$avatarUrl = UiAvatars::make()
    ->name('John Doe')
    ->size(128)
    ->background('#ffffff')
    ->color('#000000')
    ->length(2)
    ->rounded(true)
    ->bold(true)
    ->uppercase(true)
    ->format('png')
    ->getUrl();

use BlackSheepTech\UiAvatars\UiAvatars;

// Prompts a download of the avatar to a file named 'john_doe_avatar.png', by default, if a file name is not provided, a random name will be generated.

UiAvatars::make()->name('John Doe')->download('john_doe_avatar');

use BlackSheepTech\UiAvatars\UiAvatars;

// Saves the avatar to 'avatars/john_doe_avatar.png' by default.
$avatarPath = UiAvatars::make()->name('John Doe')->saveTo('avatars', 'john_doe_avatar');

// You can provided the disk to be used as the third parameter, by default, the application's default disk will be used.
$avatarPath = UiAvatars::make()->name('John Doe')->saveTo('avatars', 'john_doe_avatar', 'public');