web-push-bundle icon indicating copy to clipboard operation
web-push-bundle copied to clipboard

[Symfony 6] Problems with the "minishlink_web_push" service

Open vadegangas opened this issue 2 years ago • 4 comments

Good morning

install the Minishlink/web-push-bundle v6.0.3 package on a symfony 6.

When trying to recover the service as the documentation says:

$webPush = $this->container->get('minishlink_web_push');

symfony complains that the indicated service is not found in the container.

So try dependency injection:

use Doctrine\Persistence\ManagerRegistry; use Minishlink\WebPush\WebPush;

class functionsNotifications { public function __construct(private WebPush $webPush, private ManagerRegistry $doctrine) {}

public function notify()
{
    dd($this->webPush);
}

}

but symfony throws the error

Cannot autowire service "App\Utils\NotificationFunctions": argument "$webPush" of method "__construct()" references class "Minishlink\WebPush\WebPush" but no such service exists. You should maybe alias this class to the existing "minishlink_web_push" service.

I would appreciate any help.

vadegangas avatar Mar 17 '23 15:03 vadegangas

Hello, this bundle might not be compatible with the latest symfony versions, I haven't updated it in a while. There might have been a change in Symfony in how bundles are loaded, feel free to send a PR :) Otherwise you can use this other bundle that uses web-push, the same library that this bundle uses https://github.com/bpolaszek/webpush-bundle

Minishlink avatar Mar 17 '23 16:03 Minishlink

Good again.

Thank you for your quick answer.

The bundle that you recommend requires pairing the endpoints with users and in my case that is not possible.

I'll look to see if I can find another.

It's a shame it doesn't last.

all the best.

vadegangas avatar Mar 17 '23 21:03 vadegangas

Hi @vadegangas , I know I'm late to this conversation, but you can still make this alias in your application and still using this bundle with Symfony 6:

Inside services.yaml:

services:

    //...

    Minishlink\WebPush\WebPush: '@minishlink_web_push'

Anyway, I can make a PR adding this alias in this bundle to avoid manually add it in every app that uses this bundle.

It's ok for you @Minishlink @stephanvierkant ?

franciscosantamaria avatar Feb 11 '24 09:02 franciscosantamaria

Hello @franciscosantamaria, yes please if you can make it easer for others please do 🙏🏻

Minishlink avatar May 04 '24 10:05 Minishlink