jorenvh/laravel-share

Non-static method Jorenvh\Share\Share::currentPage() should not be called statically

Closed this issue · 4 comments

According to the README.md, we have to use it like that, but it leads to this error: Non-static method Jorenvh\Share\Share::currentPage() should not be called statically. As it says, it is caused by using page or currentPage method statically on Share class, but the page method is not defined statically.
I think this can be resolved by changing those methods statically. Like this:

public static function page(...)
{
...
}

Or alternatively, using the ShareFacade instead.

P.S: I have followed the installation and the alias is defined.

You are using the class instead of the facade. Try using https://github.com/jorenvh/laravel-share/blob/master/src/ShareFacade.php

Right, that's what I wrote on my issue. The problem is you are giving wrong information in your README.md on how to use it. This is how I'm using it:

ShareFacade::page('http://jorenvanhocht.be')->facebook();

@majidalaeinia I will see if I can improve the documentation, I assumed the Facade was already registered as an Alias.

We can always call it non-statically

return $shareComponent = (new \Jorenvh\Share\Share)->page(
'https://www.test.com',
'Your share text comes here'
)
->facebook()
->twitter()
->linkedin()
->telegram()
->whatsapp()
->reddit();