PHP code example of luckyboy1001 / avatarate

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

    

luckyboy1001 / avatarate example snippets


composer 

php artisan vendor:publish --provider=Avatarate\AvatarateServiceProvider


    $name = "Mohammad Mohammadi";
    
    $background_color = 'random'; 
    
    $text_color = [220, 120, 12, 1]; // rgb or rgba or random
    
    $shape = "circle"; // rectangle, circle
    
    $size = 240;


    $image = new \Avatarate\Services\AvatarBuilder(
        $name,
        $background_color,
        $text_color,
        $shape,
        $size
    );

    $result = $image->generate();
    


{
    status: "success",
    file_name: "avatarate-1634383742",
    path: "path-to-laravel-project/public/avatarate/avatarate-1634383742.png"
}