PHP code example of dwr / avatar-bundle
1. Go to this page and download the library: Download dwr/avatar-bundle 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/ */
dwr / avatar-bundle example snippets php
public function indexAction()
{
$avatar = new AvatarFactory();
//for plainAvatar
$plainAvatar = $avatar->generate(new PlainAvatar(140, 140));
//for profileAvatar
$profileAvatar = $avatar->generate(new ProfileAvatar(140, 140));
return array(
'plainAvatar' => $plainAvatar->render()
'profileAvatar' => $profileAvatar->render()
);
}
bash
$ php composer.phar
php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Dwr\AvatarBundle\DwrAvatarBundle(),
);
}
php
public function indexAction()
{
$avatar = new AvatarFactory();
//for plainAvatar
$plainAvatar = $avatar->generate(new PlainAvatar(140, 140));
//for profileAvatar
$profileAvatar = $avatar->generate(new ProfileAvatar(140, 140));
return array(
'plainAvatar' => $plainAvatar->render()
'profileAvatar' => $profileAvatar->render()
);
}
php
public function indexAction()
{
$avatar = new AvatarFactory();
$plainAvatar = $avatar->generate(new PlainAvatar(140, 140));
return array(
'plainAvatar' => $plainAvatar->save('web/images/avatar/directory')
);
}
php
$filename = date('YmdHis') . uniqid() . '.jpg';
php
public function indexAction()
{
$avatar = new AvatarFactory();
$plainAvatar = $avatar->generate(new PlainAvatar(140, 140));
return array(
'plainAvatar' => $plainAvatar->save('web/images/avatar/directory', 'image.jpg')
);
}