38 questions
1
vote
1
answer
110
views
How do I autoload Doctrine entities mappings in a Symfony compiler pass?
I'm trying to automatically load entity mappings based on a folder structure. My loader class returns a map like this array below. My goal is to find all "capabilities" and map their domain ...
0
votes
1
answer
460
views
How does Symfony find AsEventListener classes?
I have found a $container->registerAttributeForAutoconfiguration call here but as far as I can tell this does not add classes to the container. Yet the documentation says
An alternative way to ...
0
votes
0
answers
54
views
CMS Module agnostic with dependency injection (symfony, dependency-injection, container)
I'm trying to develop a library in PHP. This library will be used in modules for CMS (Wordpress, Drupal, PrestaShop for example).
Each CMS has different specificities and very special ways of doing ...
3
votes
0
answers
244
views
Are anonymous inline invokable factories possible with Symfony?
I can define anonymous inline factory (Symfony 6+) like this:
GuzzleClient1:
class: GuzzleHttp\ClientInterface
factory: [ !service { class: 'App\GuzzleClientFactory', calls: [ { 'withBaseUri': ...
1
vote
1
answer
2k
views
What Did I Do Wrong Here With Shopware 6 Product.Loaded Event
I created a bare minimum Shopware 6 plugin to display product ID when the product is loaded. It worked fine. Below is my code.
PATH: src/Resources/config/services.xml
<?xml version="1.0&...
-1
votes
2
answers
2k
views
The > "Symfony\Component\DependencyInjection\ContainerInterface" autowiring > alias is deprecated. How eliminate it on symfony 5.1? [duplicate]
I am migrating an application from Symfony 4.4 to Symfony 5.4. In the case of forms, I have a form that I pass in the constructor a variable ContainerInterface $container to use a parameter in the ...
1
vote
1
answer
4k
views
Passing dynamic arguments to service factory in Symfony
I'm integrating Symfony into an older application having its own dependency container based on PSR-11. Been searching for a solution to merge that DI container to the one Symfony uses, but found ...
0
votes
1
answer
2k
views
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 ...
2
votes
1
answer
2k
views
Circular reference problem with decorated service
As the documentation suggests I wrote this service to add the uuid to the normalized object:
<?php
namespace App\Serializer;
use InvalidArgumentException;
use Symfony\Component\Serializer\...
0
votes
1
answer
1k
views
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 ...
1
vote
2
answers
307
views
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: ...
0
votes
0
answers
54
views
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-&...
1
vote
0
answers
315
views
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 "...
0
votes
1
answer
1k
views
Symfony 4 autowiring argument not working
I'm trying to autowire the UrlGeneratorInterface into a DTO to use the generate method in my DTO,
I have this in my DTO:
namespace App\DTO;
use JMS\Serializer\Annotation as Serializer;
use JMS\...
2
votes
0
answers
957
views
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 ...
3
votes
0
answers
4k
views
Unused binding error when trying to bind logger to autowired controller constructor in Symfony 3.4
After upgrading to Symfony 3.4 from 2.8, I am attempting to get rid of warnings about using services from the container. One hang up is my controller all extend from an abstract controller which needs ...
4
votes
1
answer
18k
views
Symfony DI: Uncaught ArgumentCountError: Too few arguments to function App::__construct(), 0 passed in index.php on line 28 and exactly 1 expected
I'm trying to implement Symfonys dependency injection container.
I have 2 containers set, one for the database, and one for the system user.
and I'm using addArgument() to both the App class and ...
0
votes
1
answer
605
views
Symfony compile annotated classes
I'm interested in Symfony\Component\HttpKernel\DependencyInjection\Extension::getAnnotatedClassesToCompile() method. If I understand it correctly, you can addAnnotatedClassesToCompile() an array of ...
1
vote
1
answer
343
views
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
...