1. Go to this page and download the library: Download abdullah-karam/laravel-svg 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/ */
abdullah-karam / laravel-svg example snippets
namespace App\Http\Controllers;
use Abdullah\LaravelSvg\Facades\LaravelSvg;
use App\Models\User;
class UserController extends Controller
{
public function generateSvg(User $user)
{
$svgDetails = LaravelSvg::svgFor(words: $user->fullname)->generate();
dd($svgDetails);
}
}
namespace App\Http\Controllers;
use Abdullah\LaravelSvg\Facades\LaravelSvg;
use App\Models\User;
class UserController extends Controller
{
public function generateSvg(User $user)
{
$svgDetails = LaravelSvg::svgFor(words: $user->fullname)
->logoText()->generate();
dd($svgDetails);
}
}
return [
'folder' => 'storage', ## default folder name in public folder
'default_logo_text' => 'logo', ## default logo text
'logo_text_color' => '#000000',
'avatar_text_color' => '#f1c40f',
'avatar_background_color' => '#ffffff',
'default_svg_path' => 'users', ## folder name will be created in public/{folder}/users
'hash_svg_name' => true ## if you want to hash svg name by default true
];