PHP code example of jamosaur / avtr-io

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

    

jamosaur / avtr-io example snippets


// Construct with email.
$avtr = new Avtr('[email protected]');

// Construct with name.
$avtr = new Avtr('James Wallen-Jones');

// Construct with initials.
$avtr = new Avtr('JW');

// Image Format. (png, jpg, gif)
$avtr->format(string);

// Setting a first name.
$avtr->firstName(string);

// Setting a last name.
$avtr->lastName(string);

// Setting the letter count. (1, 2)
// Anything below 1 will default to 1.
// Anything above 2 will default to 2.
$avtr->letterCount(int);

// Setting the background colour.
// Values below 0 will default to 0.
// Values above 255 will default to 255.
// Alpha value is 0.0 - 1.0
$avtr->background(r, g, b, a);

// Setting the image size.
// Values below 0 will default to 100
$avtr->size(500);

// Setting rounded corners.
$avtr->roundedCorners(bool);

// Setting Shape. (square, circle)
$avtr->shape(string);

// Setting theme. (material, flat)
$avtr->theme(string);

// Setting text Case. (lower, upper, title)
$avtr->textCase(string);

// Setting text colour.
// Values below 0 will default to 0.
// Values above 255 will default to 255.
// Alpha value is 0.0 - 1.0
$avtr->color(r, g, b, a);

// Setting font weight. (100-900)
// Values below 100 default to 100
// Values above 900 default to 900
$avtr->fontWeight(100);

// Setting font. (open-sans, source-sans-pro, roboto)
$avtr->font(string);

// Return a URL
$avtr->toUrl();

 php
tr = new Avtr('James Wallen-Jones');

echo '<img src="' . $avtr->toUrl() . '">';