Git Product home page Git Product logo

Comments (10)

migo315 avatar migo315 commented on May 20, 2024

This should work normally. The we have defined an alias for the FeatureManagerInterface here: https://github.com/bestit/flagception-bundle/blob/3.x/src/Resources/config/services.yml#L9

Do you have activate autowire in your project (https://symfony.com/doc/current/service_container/autowiring.html)?

# config/services.yaml
services:
    _defaults:
        autowire: true

from flagception-bundle.

dsentker avatar dsentker commented on May 20, 2024

Yes:

services:
    _defaults:
        autowire:      true
        autoconfigure: true
        bind:
            $projectDir: '%kernel.project_dir%'

The same thing happens if I type-hint the FeatureManager instead of the FeatureManagerInterface.

Maybe it is because flagception.manager.feature_manager is not autowired / autoconfigured?

λ php bin/console debug:container Flagception

 Select one of the following services to display its information:
  [0 ] flagception.configurator.array_configurator
  [1 ] flagception.configurator.constraint_configurator
  [2 ] flagception.configurator.environment_configurator
  [3 ] flagception.configurator.contentful_configurator
  [4 ] flagception.configurator.cookie_configurator
  [5 ] flagception.manager.feature_manager
  [6 ] flagception.expression_language
  [7 ] flagception.twig.toggle_extension
  [8 ] flagception.profiler.feature_data_collector
  [9 ] flagception.bag.feature_result_bag
  [10] flagception.bag.feature_config_bag
  [11] flagception.constraint.constraint_resolver
  [12] flagception.factory.expression_language_factory
  [13] flagception.constraint_provider.date_provider
  [14] flagception.constraint_provider.match_provider
  [15] flagception.activator.chain_activator
  [16] flagception.decorator.chain_decorator
  [17] flagception.listener.routing_metadata_subscriber
  [18] flagception.activator.array_activator
  [19] flagception.activator.constraint_activator
  [20] flagception.activator.environment_activator
 > 5


Information for Service "flagception.manager.feature_manager"
=============================================================

 Class FeatureManager

 ---------------- -------------------------------------
  Option           Value
 ---------------- -------------------------------------
  Service ID       flagception.manager.feature_manager
  Class            Flagception\Manager\FeatureManager
  Tags             -
  Public           yes
  Synthetic        no
  Lazy             no
  Shared           yes
  Abstract         no
  Autowired        no
  Autoconfigured   no
 ---------------- -------------------------------------

from flagception-bundle.

dsentker avatar dsentker commented on May 20, 2024

If i inject the FeatureManager manually, it works too.

App\Foo\Bar:
    arguments: ['@flagception.manager.feature_manager']

from flagception-bundle.

migo315 avatar migo315 commented on May 20, 2024

The same thing happens if I type-hint the FeatureManager instead of the FeatureManagerInterface.

Yes, the FeatureManger is not aliased and should not work. But FeatureManagerInterface should work. We use always flagception with autowire. I don't have to define this manually in any project until now. That's very strange.

Maybe it is because flagception.manager.feature_manager is not autowired / autoconfigured?

No, thats irrelevant.

I will try to reproduce it in the next days. You can set it manually until it is solved (like you already do).

from flagception-bundle.

migo315 avatar migo315 commented on May 20, 2024

Which version do you have installed?

from flagception-bundle.

dsentker avatar dsentker commented on May 20, 2024

Thank you for your help.
flagception/flagception 1.5.0
flagception/flagception-bundle 3.0.0
Symfony 4.4.5

from flagception-bundle.

dsentker avatar dsentker commented on May 20, 2024

I created an example repository which reproduces this issue:
https://github.com/dsentker/flagception-invalid-autowiring
The FeatureManagerInterface injection is here: App\Service\FooService::__construct()
I created two simple tests to check if the service is injected correct. Alternatively, you can start the application with symfony serve and use your browser to access the start page.

In addition I have the following comments:

  • I first tried to use symfony new xyz --full --version=4.4. With this setup, i was not able to install this bundle with composer due to the following error. It seems that the ToggleExtension refers to the deprecated Twig_Extension class.

CRITICAL [php] Uncaught Error: Class 'Twig_Extension' not found ["exception" => Error { …}]
In ToggleExtension.php line 17:
!! Attempted to load class "Twig_Extension" from the global namespace.
!! Did you forget a "use" statement?

  • I then copied the relevant parts of my composer.json, which I also use in my application (where the problem occurred). Then i was able to install your bundle.
  • The entries from composer.json come from an installation of Symfony 4.1, which I then updated regularly with composer update up to version 4.4.5. But I don't think that's relevant.

I hope that helps!

from flagception-bundle.

dsentker avatar dsentker commented on May 20, 2024

OK, sorry for the comment spam, but i found the issue.

I installed your bundle with composer require flagception/flagception-bundle. For a reason i do not know, composer decided to add the following line to my composer.json: "flagception/flagception-bundle": "3",

This is wrong, as this states that the v3.0.0 is requested (instead of 3.5.1). The 3.0.0 version from your bundle is missing the Interface-alias line in the services.yaml.

So the solution is too simple: I changed the line in the composer.json to "flagception/flagception-bundle": "^3" and now it works.

The only question that remains: Why does composer write the explicit reference to version 3.0.0 ("3") in the composer.json?

from flagception-bundle.

dsentker avatar dsentker commented on May 20, 2024

I created #76 to avoid misunderstandings (so, and now I'm no longer annoying) ;-)

from flagception-bundle.

migo315 avatar migo315 commented on May 20, 2024

Thanks for your work. ;-)

I think we can close this issue.

from flagception-bundle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.