PHP code example of zertex / yii2-avatar-generator

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

    

zertex / yii2-avatar-generator example snippets


'components' => [
    ...
    'avatar' => [
        'class' => \zertex\avatar_generator\AvatarGenerator::class,
        'images_folder' => 'path_to_image_files',
        'images_url' => 'url_to_image_files',
        'size_width' => 300,            // default: 300
        'font' => 'path_to_ttf_font',   // default: Play-Bold // may use aliases
        'font_size' => 200,             // default: 200
        'salt' => 'random_salt',        // salt for image file names
        'texture' => ['sun', 'rain'],   // texture name
        'text_over_image' => true,      // draw text over image (for avatar from file)
        'texture_over_image' => true,   // draw texture over image (for avatar from file)
    ],
],
html
<?= Yii::$app->avatar->show('John Smith') 
html
<?= Yii::$app->avatar->show('John Smith', 150) 
html
<?= Yii::$app->avatar->show('John Smith', null, '/path/JM_Avatar.jpg') 
html
<?= Yii::$app->avatar->show('John Smith', null, 'http://site.org/JM_Avatar.jpg') 
html
<?= Yii::$app->avatar->show('John Smith', 150, '/path/JM_Avatar.jpg')