Questions tagged [symfony-dependency-injection]

35 questions
1
vote
2 answers

Using Symfony2 service definitions in Symfony4, with multiple services for the same class

I have the following service definition in Symfony2 app.service_1: class: Symfony\Component\Lock\Store\RedisStore arguments: - '@snc_redis.default_cache' app.service_2: class: Symfony\Component\Lock\Store\RedisStore arguments: …
Unnikrishnan
  • 2,683
  • 5
  • 22
  • 39
1
vote
0 answers

Symfony Dependency Injector and Setting up Doctrine

I have a project using a small amount of Symfony components, including dependency injection. Mainly for a small command-line project. Yesterday, I refactored to use Dependency injection, and now I'm trying to refactor and bring Doctrine into the…
1
vote
0 answers

service error after upgraded from symfony 3.3 to symfony 3.4

I've upgraded my symfony projet version from 3.3 to 3.4 a few month ago and everything woked find but i recently tried to ad an event listener and then i've got that error The configuration key "public" cannot be used to define a default value in…
je-buy 01
  • 35
  • 8
1
vote
0 answers

Symfony DI Component - How to make some services public and accessible by interface classname

Using DI as a standalone component in the small part of the codebase I want to make some services visible outside this part and accessible as by interface class name. As I know, I should use a container for this. So when old part of the code (that…
1
vote
1 answer

Lazy load services dynamically

After watching the Laravell Nova presentation I wanted to create similar functionality to Lenses in my own app. I have the following concepts: Entity: Standard Doctrine Entity Resource: A class that describes a resource including the target entity…
Leevi Graham
  • 654
  • 8
  • 19
1
vote
1 answer

Resolving Dependency Conflicts Installing Behat and Laravel 5.3

Hello I am trying to install behat/behat via composer, however I am have dependency problems. I tried the below of many: composer require behat/behat:"3.*" symfony/dependency-injection:"3.*" --dev However, the output of above is Your requirements…
xiarnousx
  • 575
  • 6
  • 18
0
votes
0 answers

services.yaml being ignored in symfony 6.3?

Upgraded a Symfony project from v 4 to v6.3 and my autowiring is no longer working, it seems that the services.yaml is being ignored but cannot figure out why.
André Figueira
  • 6,048
  • 14
  • 48
  • 62
0
votes
1 answer

Cannot load DI inside controller constructor

I am trying to follow the Build you own framework tutorial. I get stuck when I want to use DI inside my controller. I have found this question (Controller (Service) not having dependencies injected on Symfony project) on stack overflow that got me…
0
votes
0 answers

How to pass the requested service id into the factory in Symfony 5?

My Symfony project's folders structure looks like this: src API V1 Systems System1 Platform.php System2 Platform.php System3 Platform.php SystemN .............. I want to create my services via Multiple Service Definitions…
0
votes
1 answer

Explain These Services.xml File Terms In Shopware 6

What does argument and argument type mean, What does tag and tag name mean, in Shopware 6 plugin services.xml file?
0
votes
1 answer

Symfony DependencyInjection class cannot be declared because the name is already in use

I created a new symfony 5.3 project. I'm developing this app using hexagonal architecture. I added a Bundle I developed for another symfony project. This bundle is working in the original project. But in the new project I get the following…
0
votes
1 answer

Symfony DependencyInjection : import multiple resources (yaml)

I am trying to implement Symfony Dependency Injection Component (https://symfony.com/doc/current/components/dependency_injection.html) in a non Symfony project. It works well if I put all my services and parameters into a single "services.yaml"…
0
votes
2 answers

Symfony: Use a value within a parameter array as a service parameter

Symfony 3.4 I have a parameter that looks like this: parameters.yml: paramters: some_configuration: param1: value1 param2: value2 I want to pass a value within my some_configuration parameter directly to a service, rather that…
amacrobert
  • 2,707
  • 2
  • 28
  • 37
0
votes
1 answer

How to use doctrine in custom bundle controllers - "Controller has required constructor arguments and does not exist in the container. "

I have a Symfony 5.3 project with two custom reusabale bundles. I have created an Entity in bundle1, I want to be able to read and write to this from within bundle2 However, I cannot successfully include the Doctrine in any of my bundle…
LeeTee
  • 6,401
  • 16
  • 79
  • 139
0
votes
0 answers

How handle router with container's services/parameters dynamically?

I've used the Symfony route bundle and DI bundle in my non Symfony project. I inject dependencies to the controllers/actions by the code below: // Find the current route $parameters = $router->match($requestContext->getPathInfo()); …
Fatemeh Gharri
  • 369
  • 2
  • 6
  • 20