Comments (14)
...
use Laravolt\Avatar\Facade as Avatar;
...
public function index()
{
return Avatar::create("Bayu Hendra")->toBase64();
}
...
from avatar.
Please make sure you have correct alias config:
'Avatar' => Laravolt\Avatar\Facade::class,
or if don't want to use alias, you must import the facade class, not the actual Avatar class, e.g:
use Laravolt\Avatar\Facade
from avatar.
try like this:
$user_image = (new \Laravolt\Avatar\Avatar)->create('text')->toBase64();
from avatar.
Hello,
I have the same problem.
Can you put an example to use it in a Controller, please?
Thank you. :)
from avatar.
Hello,
Thank you now it works.
Regards.
from avatar.
@uyab Thank you for the example code.
Could you add this to the README example? I pasted the example code and had to google this error. Thanks again!
from avatar.
Also, this:
// Create the default image URL:
$avatar = Avatar::create($user->name);
// Save it using Storage instead of Avatar::save()
$image = $avatar->getImageObject();
Storage::put($avatar_path, $image->stream('png'));
from avatar.
Add 'Avatar' => Laravolt\Avatar\Facade::class,
on your config/app.php
then
call \Avatar::create()
work for me in Laravel 6.0
from avatar.
Hello @uyab ,
I have the same error:
"Non-static method Laravolt\\Avatar\\Avatar::create() should not be called statically"
My environment is based on Laravel 7.10.3 and PHP 7.4.6 and Apache 2.4 on Win10.
I tried to install laravolt/avatar with:
$ composer require laravolt/avatar
Using version ^3.2 for laravolt/avatar
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 2 installs, 0 updates, 0 removals
- Installing intervention/image (2.5.1): Loading from cache
- Installing laravolt/avatar (3.2.1): Downloading (100%)
intervention/image suggests installing ext-imagick (to use Imagick based image processing.)
intervention/image suggests installing intervention/imagecache (Caching extension for the Intervention Image library)
Writing lock file
Generating optimized autoload files
I included in my config/app.php:
Laravolt\Avatar\ServiceProvider::class,
...
'Avatar' => Laravolt\Avatar\Facade::class,
Because the command:
php artisan vendor:publish --provider="Laravolt\Avatar\ServiceProvider"
Did not automatically provide to my app.php file and in my controller, I use that:
use Laravolt\Avatar\Avatar;
...
$avatar = Avatar::create($user->name);
$image = $avatar->getImageObject();
Storage::put('avatars/'.$user->id.'/avatar.png', $image->stream('png'));
I tried to change this:
use Laravolt\Avatar\Avatar;
by this:
use Laravolt\Avatar\Facade as Avatar;
and result was the same... =(
Here is my error stack:
[2020-05-19 22:27:57] local.ERROR: Non-static method Laravolt\Avatar\Avatar::create() should not be called statically {"exception":"[object] (ErrorException(code: 0): Non-static method Laravolt\\Avatar\\Avatar::create() should not be called statically at D:\\BravoBPO\\Projetos\\www\
ew\\bravoauth\\app\\Http\\Controllers\\Api\\Auth\\v1\\AuthController.php:60)
[stacktrace]
#0 D:\\BravoBPO\\Projetos\\www\
ew\\bravoauth\\app\\Http\\Controllers\\Api\\Auth\\v1\\AuthController.php(60): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(8192, 'Non-static meth...', 'D:\\\\BravoBPO\\\\Pro...', 60, Array)
#1 [internal function]: App\\Http\\Controllers\\Api\\Auth\\v1\\AuthController->signup(Object(Illuminate\\Http\\Request))
#2 D:\\BravoBPO\\Projetos\\www\
ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Controller.php(54): call_user_func_array(Array, Array)
#3 D:\\BravoBPO\\Projetos\\www\
ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\ControllerDispatcher.php(45): Illuminate\\Routing\\Controller->callAction('signup', Array)
#4 D:\\BravoBPO\\Projetos\\www\
ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Route.php(239): Illuminate\\Routing\\ControllerDispatcher->dispatch(Object(Illuminate\\Routing\\Route), Object(App\\Http\\Controllers\\Api\\Auth\\v1\\AuthController), 'signup')
#5 D:\\BravoBPO\\Projetos\\www\
ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Route.php(196): Illuminate\\Routing\\Route->runController()
#6 D:\\BravoBPO\\Projetos\\www\
ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(685): Illuminate\\Routing\\Route->run()
#7 D:\\BravoBPO\\Projetos\\www\
ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(128): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#8 D:\\BravoBPO\\Projetos\\www\
ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Middleware\\SubstituteBindings.php(41): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#9 D:\\BravoBPO\\Projetos\\www\
ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#10 D:\\BravoBPO\\Projetos\\www\
ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Middleware\\ThrottleRequests.php(59): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#11 D:\\BravoBPO\\Projetos\\www\
ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Illuminate\\Routing\\Middleware\\ThrottleRequests->handle(Object(Illuminate\\Http\\Request), Object(Closure), 60, '1')
#12 D:\\BravoBPO\\Projetos\\www\
ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#13 D:\\BravoBPO\\Projetos\\www\
ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(687): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#14 D:\\BravoBPO\\Projetos\\www\
ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(662): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request))
#15 D:\\BravoBPO\\Projetos\\www\
ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(628): Illuminate\\Routing\\Router->runRoute(Object(Illuminate\\Http\\Request), Object(Illuminate\\Routing\\Route))
#16 D:\\BravoBPO\\Projetos\\www\
ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(617): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request))
#17 D:\\BravoBPO\\Projetos\\www\
ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(165): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request))
#18 D:\\BravoBPO\\Projetos\\www\
ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(128): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(Illuminate\\Http\\Request))
#19 D:\\BravoBPO\\Projetos\\www\
ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#20 D:\\BravoBPO\\Projetos\\www\
ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#21 D:\\BravoBPO\\Projetos\\www\
ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#22 D:\\BravoBPO\\Projetos\\www\
ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#23 D:\\BravoBPO\\Projetos\\www\
ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#24 D:\\BravoBPO\\Projetos\\www\
ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#25 D:\\BravoBPO\\Projetos\\www\
ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode.php(63): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#26 D:\\BravoBPO\\Projetos\\www\
ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#27 D:\\BravoBPO\\Projetos\\www\
ew\\bravoauth\\vendor\\fruitcake\\laravel-cors\\src\\HandleCors.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#28 D:\\BravoBPO\\Projetos\\www\
ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Fruitcake\\Cors\\HandleCors->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#29 D:\\BravoBPO\\Projetos\\www\
ew\\bravoauth\\vendor\\fideloper\\proxy\\src\\TrustProxies.php(57): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#30 D:\\BravoBPO\\Projetos\\www\
ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Fideloper\\Proxy\\TrustProxies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#31 D:\\BravoBPO\\Projetos\\www\
ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#32 D:\\BravoBPO\\Projetos\\www\
ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(140): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#33 D:\\BravoBPO\\Projetos\\www\
ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(109): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#34 D:\\BravoBPO\\Projetos\\www\
ew\\bravoauth\\public\\index.php(55): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#35 {main}
"}
In another early versions of Laravel, like 5.2 ~ 5.6 or 6.0 ~ 6.7, this work propertly.
Thanks in advanced for any help
from avatar.
Hello @uyab ,
I have the same error:
"Non-static method Laravolt\\Avatar\\Avatar::create() should not be called statically"
My environment is based on Laravel 7.10.3 and PHP 7.4.6 and Apache 2.4 on Win10.
I tried to install laravolt/avatar with:
$ composer require laravolt/avatar Using version ^3.2 for laravolt/avatar ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 2 installs, 0 updates, 0 removals - Installing intervention/image (2.5.1): Loading from cache - Installing laravolt/avatar (3.2.1): Downloading (100%) intervention/image suggests installing ext-imagick (to use Imagick based image processing.) intervention/image suggests installing intervention/imagecache (Caching extension for the Intervention Image library) Writing lock file Generating optimized autoload files
I included in my config/app.php:
Laravolt\Avatar\ServiceProvider::class, ... 'Avatar' => Laravolt\Avatar\Facade::class,
Because the command:
php artisan vendor:publish --provider="Laravolt\Avatar\ServiceProvider"
Did not automatically provide to my app.php file and in my controller, I use that:
use Laravolt\Avatar\Avatar; ... $avatar = Avatar::create($user->name); $image = $avatar->getImageObject(); Storage::put('avatars/'.$user->id.'/avatar.png', $image->stream('png'));
I tried to change this:
use Laravolt\Avatar\Avatar;
by this:
use Laravolt\Avatar\Facade as Avatar;
and result was the same... =(
Here is my error stack:[2020-05-19 22:27:57] local.ERROR: Non-static method Laravolt\Avatar\Avatar::create() should not be called statically {"exception":"[object] (ErrorException(code: 0): Non-static method Laravolt\\Avatar\\Avatar::create() should not be called statically at D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\app\\Http\\Controllers\\Api\\Auth\\v1\\AuthController.php:60) [stacktrace] #0 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\app\\Http\\Controllers\\Api\\Auth\\v1\\AuthController.php(60): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(8192, 'Non-static meth...', 'D:\\\\BravoBPO\\\\Pro...', 60, Array) #1 [internal function]: App\\Http\\Controllers\\Api\\Auth\\v1\\AuthController->signup(Object(Illuminate\\Http\\Request)) #2 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Controller.php(54): call_user_func_array(Array, Array) #3 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\ControllerDispatcher.php(45): Illuminate\\Routing\\Controller->callAction('signup', Array) #4 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Route.php(239): Illuminate\\Routing\\ControllerDispatcher->dispatch(Object(Illuminate\\Routing\\Route), Object(App\\Http\\Controllers\\Api\\Auth\\v1\\AuthController), 'signup') #5 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Route.php(196): Illuminate\\Routing\\Route->runController() #6 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(685): Illuminate\\Routing\\Route->run() #7 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(128): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request)) #8 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Middleware\\SubstituteBindings.php(41): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request)) #9 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle(Object(Illuminate\\Http\\Request), Object(Closure)) #10 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Middleware\\ThrottleRequests.php(59): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request)) #11 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Illuminate\\Routing\\Middleware\\ThrottleRequests->handle(Object(Illuminate\\Http\\Request), Object(Closure), 60, '1') #12 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request)) #13 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(687): Illuminate\\Pipeline\\Pipeline->then(Object(Closure)) #14 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(662): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request)) #15 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(628): Illuminate\\Routing\\Router->runRoute(Object(Illuminate\\Http\\Request), Object(Illuminate\\Routing\\Route)) #16 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(617): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request)) #17 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(165): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request)) #18 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(128): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(Illuminate\\Http\\Request)) #19 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request)) #20 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure)) #21 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request)) #22 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure)) #23 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request)) #24 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure)) #25 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode.php(63): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request)) #26 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Illuminate\\Http\\Request), Object(Closure)) #27 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\fruitcake\\laravel-cors\\src\\HandleCors.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request)) #28 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Fruitcake\\Cors\\HandleCors->handle(Object(Illuminate\\Http\\Request), Object(Closure)) #29 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\fideloper\\proxy\\src\\TrustProxies.php(57): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request)) #30 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Fideloper\\Proxy\\TrustProxies->handle(Object(Illuminate\\Http\\Request), Object(Closure)) #31 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request)) #32 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(140): Illuminate\\Pipeline\\Pipeline->then(Object(Closure)) #33 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(109): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request)) #34 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\public\\index.php(55): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request)) #35 {main} "}
In another early versions of Laravel, like 5.2 ~ 5.6 or 6.0 ~ 6.7, this work propertly.
Thanks in advanced for any help
[Solved]I discovered that I need to use in my controller:
use Avatar;
from avatar.
Hello @uyab ,
I have the same error:"Non-static method Laravolt\\Avatar\\Avatar::create() should not be called statically"
My environment is based on Laravel 7.10.3 and PHP 7.4.6 and Apache 2.4 on Win10.
I tried to install laravolt/avatar with:$ composer require laravolt/avatar Using version ^3.2 for laravolt/avatar ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 2 installs, 0 updates, 0 removals - Installing intervention/image (2.5.1): Loading from cache - Installing laravolt/avatar (3.2.1): Downloading (100%) intervention/image suggests installing ext-imagick (to use Imagick based image processing.) intervention/image suggests installing intervention/imagecache (Caching extension for the Intervention Image library) Writing lock file Generating optimized autoload files
I included in my config/app.php:
Laravolt\Avatar\ServiceProvider::class, ... 'Avatar' => Laravolt\Avatar\Facade::class,
Because the command:
php artisan vendor:publish --provider="Laravolt\Avatar\ServiceProvider"
Did not automatically provide to my app.php file and in my controller, I use that:
use Laravolt\Avatar\Avatar; ... $avatar = Avatar::create($user->name); $image = $avatar->getImageObject(); Storage::put('avatars/'.$user->id.'/avatar.png', $image->stream('png'));
I tried to change this:
use Laravolt\Avatar\Avatar;
by this:
use Laravolt\Avatar\Facade as Avatar;
and result was the same... =(
Here is my error stack:[2020-05-19 22:27:57] local.ERROR: Non-static method Laravolt\Avatar\Avatar::create() should not be called statically {"exception":"[object] (ErrorException(code: 0): Non-static method Laravolt\\Avatar\\Avatar::create() should not be called statically at D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\app\\Http\\Controllers\\Api\\Auth\\v1\\AuthController.php:60) [stacktrace] #0 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\app\\Http\\Controllers\\Api\\Auth\\v1\\AuthController.php(60): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(8192, 'Non-static meth...', 'D:\\\\BravoBPO\\\\Pro...', 60, Array) #1 [internal function]: App\\Http\\Controllers\\Api\\Auth\\v1\\AuthController->signup(Object(Illuminate\\Http\\Request)) #2 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Controller.php(54): call_user_func_array(Array, Array) #3 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\ControllerDispatcher.php(45): Illuminate\\Routing\\Controller->callAction('signup', Array) #4 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Route.php(239): Illuminate\\Routing\\ControllerDispatcher->dispatch(Object(Illuminate\\Routing\\Route), Object(App\\Http\\Controllers\\Api\\Auth\\v1\\AuthController), 'signup') #5 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Route.php(196): Illuminate\\Routing\\Route->runController() #6 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(685): Illuminate\\Routing\\Route->run() #7 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(128): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request)) #8 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Middleware\\SubstituteBindings.php(41): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request)) #9 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle(Object(Illuminate\\Http\\Request), Object(Closure)) #10 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Middleware\\ThrottleRequests.php(59): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request)) #11 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Illuminate\\Routing\\Middleware\\ThrottleRequests->handle(Object(Illuminate\\Http\\Request), Object(Closure), 60, '1') #12 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request)) #13 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(687): Illuminate\\Pipeline\\Pipeline->then(Object(Closure)) #14 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(662): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request)) #15 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(628): Illuminate\\Routing\\Router->runRoute(Object(Illuminate\\Http\\Request), Object(Illuminate\\Routing\\Route)) #16 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(617): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request)) #17 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(165): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request)) #18 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(128): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(Illuminate\\Http\\Request)) #19 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request)) #20 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure)) #21 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request)) #22 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure)) #23 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request)) #24 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure)) #25 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode.php(63): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request)) #26 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Illuminate\\Http\\Request), Object(Closure)) #27 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\fruitcake\\laravel-cors\\src\\HandleCors.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request)) #28 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Fruitcake\\Cors\\HandleCors->handle(Object(Illuminate\\Http\\Request), Object(Closure)) #29 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\fideloper\\proxy\\src\\TrustProxies.php(57): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request)) #30 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(167): Fideloper\\Proxy\\TrustProxies->handle(Object(Illuminate\\Http\\Request), Object(Closure)) #31 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request)) #32 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(140): Illuminate\\Pipeline\\Pipeline->then(Object(Closure)) #33 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(109): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request)) #34 D:\\BravoBPO\\Projetos\\www\ ew\\bravoauth\\public\\index.php(55): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request)) #35 {main} "}
In another early versions of Laravel, like 5.2 ~ 5.6 or 6.0 ~ 6.7, this work propertly.
Thanks in advanced for any help[Solved]I discovered that I need to use in my controller:
use Avatar;
This results in
Error
Class name must be a valid object or a string
I added:
config/app.php >in providers
Laravolt\Avatar\ServiceProvider::class,
app.php >in aliases
'Avatar' => Laravolt\Avatar\Facade::class,
Tried
use Avatar;
and
use Laravolt\Avatar\Facade as Avatar;
and
use Laravolt\Avatar\Avatar;
Controller:
return Avatar::create(Session::get('user')->fullName)->toBase64();
Thanks in advance for any help.
from avatar.
Laravel 6.18.22
write in config/app.php
Laravolt\Avatar\ServiceProvider::class,
'Avatar' => Laravolt\Avatar\Facade::class,
php artisan vendor:publish --provider="Laravolt\Avatar\ServiceProvider"
use in controller
use Laravolt\Avatar\Avatar;
$user_image = (string) Avatar::create('text')->toBase64();
exception:
Non-static method Laravolt\Avatar\Avatar::create() should not be called statically
try to use in same controller
use Laravolt\Avatar\Facade as Avatar;
exception:
Class name must be a valid object or a string
in config/laravol/avatar.php exist 'generator' => \Laravolt\Avatar\Generator\DefaultGenerator::class,
from avatar.
_image = (new \Laravolt\Avatar\Avatar)->create('text')->toBase64();
thank you brother it's working
from avatar.
If you're using the Inertia stack, you could make this shared so that you can use the avatar across your application. For example, if you're rendering your views using react, you could go to App/Http/Middleware/HandleInertiaRequests.php
and add the following block:
public function share(Request $request)
{
return array_merge(parent::share($request), [
'auth' => [
'user' => $request->user(),
'avatar' => $request->user() ? Avatar::create($request->user()->name)->toBase64() : null
],
]);
}
Then just use it in your .jsx
like so: <span>{auth.avatar}</span>
. I used Breeze as a starter kit with ReactJS for front-end in this example. This also applies to vue, though syntax will change in your view rendering.
from avatar.
Related Issues (20)
- Right to left script support HOT 8
- Laravel 8.x Support HOT 3
- Serialization of 'GdImage' is not allowed HOT 4
- setTheme() border size bug HOT 3
- config is empty when using facade HOT 1
- Arabic (utf8) not working HOT 6
- Generates only default "background" and "foreground" color
- Laravel 9 support HOT 4
- Using SVG with & (ampersand) breaks XML
- font error HOT 1
- got this error HOT 3
- error while install Laravolt HOT 2
- SVGs have their width and height set rendering them unresponsive HOT 1
- Error using in Laravel Framework 9.47.0, Please help !!! HOT 1
- Laravel 10 HOT 12
- Install/usage help HOT 2
- Enhancement: Exclusion of Prepositions and Modification of Initials
- Using the 'imagick' driver, background colors are not applied/generated.
- Upgrade to intervention/image:^3.0 HOT 1
- Laravel 11 Support HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from avatar.