Comments (5)
Truthfully, I've never messed with the getSubscribedServices
method, so I'm not entirely sure that the pushers will work with it (looking at what's in the abstract controller, all of those services are referenced by a class or interface name, and the pushers aren't registered in the container with those types of IDs).
You might be better off injecting the pusher as an argument to your controller instead of using the getSubscribedServices
method. At least, https://symfony.com/doc/current/service_container/service_subscribers_locators.html doesn't give me much confidence that you can use it without having class-based service IDs.
from websocketbundle.
thanks for answer, but when I try inject pusher as argument to my controller in costructor
/**
* @Route("/api/language", name="language_api")
*/
class LanguageController extends BaseEntityController {
private WsNotificator $wsNotificator;
private PusherInterface $pusher;
public function __construct(
LoggerInterface $logger,
LanguageRepository $repository,
ProfileRepository $profileRepository,
WsNotificator $wsNotificator,
CacheInterface $cacheApp,
PusherInterface $pusher
){
parent::__construct($logger, $repository, $profileRepository, $cacheApp);
$this->wsNotificator = $wsNotificator;
$this->pusher = $pusher;
}
I get this error:
Cannot autowire service "App\Controller\LanguageController": argument "$pusher" of method "__construct()" references interface "Gos\Bundle\WebSocketBundle\Pusher\PusherInterface" but no such service exists. Did you create a class that implements this interface?
And When I try get service by name
/**
* @Route("/", name="add", methods={"GET"})
*/
public function defaultAction(Request $request): ?JsonResponse
{
/** @var PusherInterface $pusher */
$pusher = $this->get('gos_web_socket.pusher.wamp');
$pusher->push(['msg' => 'hi'], 'chat.topic');
die;
}
I get error:
Service "gos_web_socket.pusher.wamp" not found: even though it exists in the app's container, the container inside "App\Controller\LanguageController" is a smaller service locator that only knows about the "doctrine", "form.factory", "http_kernel", "message_bus", "messenger.default_bus", "parameter_bag", "request_stack", "router", "security.authorization_checker", "security.csrf.token_manager", "security.token_storage", "serializer", "session" and "twig" services. Try using dependency injection instead.
but when I try bin/console debug:container gos_web_socket.pusher, service exist
---------------- -----------------------------------------------------------------
Option Value
---------------- -----------------------------------------------------------------
Service ID gos_web_socket.pusher.wamp.data_collector
Class Gos\Bundle\WebSocketBundle\Pusher\DataCollectingPusherDecorator
Tags gos_web_socket.pusher (alias: wamp)
Public no
Synthetic no
Lazy no
Shared yes
Abstract no
Autowired no
Autoconfigured no
---------------- -----------------------------------------------------------------
Some idea? Thanks very much
from websocketbundle.
You can't use autowiring to inject pushers, they all share a common interface (and are decorated in debug mode) so nothing can reliably set an alias to Gos\Bundle\WebSocketBundle\Pusher\PusherInterface
in the service container. You're going to have to manually define that argument for your service configurations wherever you need it injected.
from websocketbundle.
I am sorry, I am newbie in symfony and I am not sure how do you think exactly.
I have registered only one pusher (wamp)
gos_web_socket:
pushers:
wamp: enabled: true
host: 127.0.0.1
port: 80
ssl: false
origin: null
You say that I have to manually define argument in my config like this?
App\Controller\LanguageController:
class: App\Controller\LanguageController:
arguments:
$pusher: '@gos_web_socket.pusher.wamp'
My controller
class LanguageController extends BaseEntityController {
private WsNotificator $wsNotificator;
private WampPusher $pusher;
public function __construct(
WampPusher $pusher,
LoggerInterface $logger,
LanguageRepository $repository,
ProfileRepository $profileRepository,
WsNotificator $wsNotificator,
CacheInterface $cacheApp
){
parent::__construct($logger, $repository, $profileRepository, $cacheApp);
$this->wsNotificator = $wsNotificator;
$this->pusher = $pusher;
}
but I get error:
Cannot autowire service "App\Controller\LanguageController": argument "$pusher" of method "__construct()" references class "Gos\Bundle\WebSocketBundle\Pusher\Wamp\WampPusher" but no such service exists.
from websocketbundle.
Same issue on prestashop v8.0.0 built on symfony
The service "PrestaShopBundle\Security\OAuth2\Repository\ClientRepository" has a dependency on a non-existent service "security.user.provider.concrete.oauth2".
from websocketbundle.
Related Issues (20)
- Connection auto closes right after first incomming message HOT 1
- Suggestion: Native TLS support HOT 5
- How define route with parameter?
- After upgrading Symfony from 5.3.0 to 5.3.13, gos:wsb gives error when client attempts to subscribe to channel HOT 4
- Push Notifications from Server HOT 1
- Error using PdoSessionHandler with symfony 6 - "VirtualSessionStorage::start() must be compatible.." HOT 3
- Session Problem PDO HOT 5
- Error installing the bundle: Undefined array key "port" HOT 2
- Uncaught ReferenceError: GosSocket is not defined HOT 2
- Please provide documentation for using the symfony messenger component as a pusher HOT 2
- Update to support modern Autobahn version. HOT 8
- New authentication flow using JWT HOT 9
- Subscribe to topic on server HOT 2
- Connection in IPV6 HOT 1
- TopicPeriodicTimer doesn't see new connections
- TopicPeriodicTimer only registered for one Topic, wrongly cleared if any one Topic has zero connections HOT 1
- How can I send a message HOT 2
- error while installing (In GosWebSocketExtension.php line 276 Notice: Undefined index: port)
- The "Gos\Bundle\WebSocketBundle\Pusher\PusherRegistry" class is deprecated and will be removed
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 websocketbundle.