Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6854953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:41:50+00:00 2026-05-27T01:41:50+00:00

I’d like to be able to wire up services from configuration parameters so that

  • 0

I’d like to be able to wire up services from configuration parameters so that I can use a mock implementation of a web service client in the dev environment and I can use the proper client in prod env.

Here is a snippet from my services.xml:

<parameters>
    ...
    <parameter key="api_client.api_service.id">ic_domain_security.api_mock_service</parameter>
    ...
</parameters>

<services>
...
    <service id="ic_domain_security.api_client"
                 class="%api_client.class%"
                 public="true">
            <tag name="monolog.logger" channel="domainApiClient"/>
            <argument type="service" id="%api_client.api_service.id%"/>
            <call method="setLogger">
                <argument type="service" id="logger" on-invalid="null"/>
            </call>
        </service>

        <service id="ic_domain_security.api_restful_webservice"
                 class="IC\DomainSecurityBundle\ApiClient\ApiRestfulWebService"
                 public="false">
            <tag name="monolog.logger" channel="domainApiRestfulWebService"/>
            <argument>%ic_domain_security.service_url%</argument>
            <argument type="service" id="logger" on-invalid="null"/>
        </service>

        <service id="ic_domain_security.api_mock_service"
                 class="IC\DomainSecurityBundle\Tests\Mock\ApiMockService"
                 public="false">
            <call method="setLogger">
                <argument type="service" id="logger" on-invalid="null"/>
            </call>
        </service>
...
</services>

The line <argument type="service" id="%api_client.api_service.id%"/> is trying to define the service to pass based on a parameter. So I’m eventually trying to push out the api_client.api_service.id parameter to configuration file(s).

Unfortunately it doesn’t appear to be possible to define service ids using parameters and I’m getting the following error:

ServiceNotFoundException: The service "ic_domain_security.api_client" has a dependency on a non-existent service "%api_client.api_service.id%".

Is there a way do what I explained above so that service ids can be passed using configuration parameters?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:41:51+00:00Added an answer on May 27, 2026 at 1:41 am

    The best way to do what you are trying to do is to define a semantic configuration for your bundle. Anyway I don’t think that you can do this without writing some PHP code.

    This means that you should write a Configuration class and a Dependency Injection Extension class. It is quite an easy process, though it is not exhaustively documented on Symfony2 docs. My advice is to take some simple bundle (e.g. I learned very much reading FOSUserBundle) and see how they define their configuration.

    Here you can find an introduction to the DIC extension system.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I would like to count the length of a string with PHP. The string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.