New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error Using the Facade #2
Comments
Same problem here. No fix idea as of yet :/ |
Same issue. |
It occurs on my project too. |
Same here |
I think this is because how the Pusher library is built. The I've have discussed a PSR-4 update to the library in pusher/pusher-http-php#25. They are about to release a new package that is more up to date with PHP. Maybe we can hold out until then and release Laravel Pusher |
Any idea on when this will be fixed? Or what we can temporarily edit to make it work? |
I was having more issues it today. I am not too familiar with the way ServiceProviders work in Laravel, so i just created a very basic service injector https://gist.github.com/mottihoresh/394e12ea802b41b5ef65 the only thing you need to do is to add pusher-php-server to your composer file. |
@mottihoresh @Kryptonit3 Have you tried using it as in our dependency injection example instead of using the facade? |
For reference how to use it with dependency injection you can check out this |
I tried using the facade and then DI and get the same error (maybe since the PusherManager also ends up using the facade?).
|
@TimothyLoyer I think its because how the Pusher library is built, it currently return the Pusher class globally. They are about to release a namespaced version soon. @GrahamCampbell do you have any idea? |
Maybe having your facade named "Pusher" is causing an issue- might be why the L4 package used "pusherer". |
@TimothyLoyer Yes, I think so too. Maybe we can hold out on this until they release the new version https://github.com/pusher/pusher-http-php/tree/new-lib |
I just renamed the facade (and continued using DI, but I imagine that the facade also works now with its new name). The area of issue is in PusherFactory, where you have |
The facades in Laravel are globally registered so its quite hard to work around. Did it work renaming it? |
Yes, and you are right about the Pusher php library- all those classes are in the global namespace (ugly!) so that forces you into working around its namespaced classes. You'll want to double check all those classnames to be sure you don't have any overlap. Though thinking about it, facades are really all that would have an issue. |
@TimothyLoyer Yeah, you can still use the |
I tweeted Pusher about namespacing their composer package and got a pretty quick response from @leggetter. "We’ve got a new-lib branch which is an completely re-written lib. v3.0 will be the last non-namespaces major release." More info here: http://j.mp/1MKUTt3 - Looks like they are moving to a 4.0 branch. |
👍 |
I can't seem to get it work with dependency injection as well. |
@jadjoubran please see #2 (comment). Yes, you could try to remove the facade from |
For the time being, I've just renamed my facade to public function pusher()
{
$messages = '{"name":"Joe","message":"Hello world!"}';
LaravelPusher::trigger('test_channel', 'my_event', ['message' => $messages]);
} in my function. My alias then has to become As mentioned above, it's because the class and facade clash for the namespace. |
Thanks CoeusCC that works like a charm. |
here is a simple package - https://github.com/Kryptonit3/Pusher |
+1 |
Just have |
any update ? |
There is no bug in this library. |
Go pester the actual pusher library to sort it out. |
solution is here not to put the facade class in |
sheyooo - exact incantation please? |
@rulatir https://github.com/vinkla/pusher#installation InstallationRequire this package, with Composer, in the root directory of your project. composer require vinkla/pusher Add the service provider to Vinkla\Pusher\PusherServiceProvider::class
'Pusher' => Vinkla\Pusher\Facades\Pusher::class //IGNORE THIS If you prefer to use dependency injection over facades like me, then you can inject the manager: use Vinkla\Pusher\PusherManager;
class Foo
{
protected $pusher;
public function __construct(PusherManager $pusher)
{
$this->pusher = $pusher;
}
public function bar()
{
$this->pusher->trigger('my-channel', 'my-event', ['message' => $message]);
}
} |
Thanks sheyooo, I just ended up writing a super simple facade by hand, one that directly wraps the Pusher class. I removed vinkla/pusher altogether. |
@rulatir You can actually use the Pusher class with this package. That is why we bind the Pusher class to the connection. Please see |
Using @GrahamCampbell suggestion solved the issue |
I still don't know how this work. Tried all of the method. |
@mhdafiq try #2 (comment) |
@vinkla i already tried that but still cannot trigger from server. when i |
@jameshfisher @luismfonseca are there any updates on the new version of the |
@GrahamCampbell @vinkla so I understand correctly, I can just add Future users of the library would always need to do |
Yes, but you need to release it as a new major version. It is a breaking change. Shouldn't be a problem though since integers are cheap. |
@luismfonseca let me know if there is anything I can help with. Please let me know before you push the new version. Then I can help you test it out. |
Btw, I've released the new php version! |
@luismfonseca great! I'll release a new version of this package with the Laravel 5.5 support release. |
ca we use facade now? |
I'll release a new version soon. |
Fixed in 25a88e4. |
The error below has been reported by @alexandredes and @mottihoresh. This error occurs when using the Facade. As I've learned, using dependency injection it works.
call_user_func_array() expects parameter 1 to be a valid callback
I've tried this in my local setup, using Homestead, with both the Facade and dependency injection without any problems. The events gets registered in the console at http://pusher.com. Example code below.
If someone else experience this, please report it here. If you have a solution, please share it!
The text was updated successfully, but these errors were encountered: