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 8552873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:31:28+00:00 2026-06-11T14:31:28+00:00

How do i refer to a data file in the services.yml, which is located

  • 0

How do i refer to a data file in the services.yml, which is located in the same or any bundle?

Im shipping a csv-file which i would like to inject as argument.
It works when i use the direct path:

mybundle.data.csv: %kernel.root_dir%/../vendor/mybundle/my-bundle/mybundle/MyBundle/Resources/data/data.csv 

This is pretty verbose and unflexible and thus i am looking for a resolver like:

data.csv: "@MyBundle/Resources/data/data.csv"

But this is not working:

… has a dependency on a non-existent service
“mybundle/resources/data/data.csv”.

any ideas?

  • 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-06-11T14:31:29+00:00Added an answer on June 11, 2026 at 2:31 pm

    First of all: in the YAML service and parameter definitions @ also refers to another service. That is why your code does not work.

    Basically you have two possibilities. The first and simple one is to use a relative path in your bundles services.yml and append it in your CSV class.

    For example:

    # src/Acme/DemoBundle/Resources/config/services.yml
    parameters:
        data.csv: "Resources/data/data.csv"
    

    In the class you want to read the CSV file:

    // src/Acme/DemoBundle/Import/ReadCsv.php
    ...
    class ReadCsv
    {
        ...
        public function __construct($csvFile)
        {
           $this->csvFile = __DIR__.'/../'.$csvFile; 
        }
        ...
    }
    

    The other possibility is to make the filename of the CSV file configurable via config.yml (see this article in the Symfony2 cookbook) and insert a special placeholder in the config value that you replace in your AcmeDemoBundleExtension class:

    // src/Acme/DemoBundle/DependencyInjection/AcmeDemoBundleExtension.php
    ...
    public function load(array $configs, ContainerBuilder $container)
    {
        ...
        $container->setParameter('acme_demo.csv_file', str_replace('__BUNDLE_DIR__', __DIR__'./.., $config['csv_file']);
    }
    ...
    

    Your config.yml would look like:

    # app/config/config.yml
    acme_demo:
        csv_file: __BUNDLE_DIR__/Resources/data/data.csv
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using data that's in a csv file to display it using JSON.
I have written an Excel VBA macro which imports data from a HTML file
Basically, I have data of several people contained in a .csv file. This spreadsheet
I have following requirement, I have C#/.Net console application, which refers to 'System.Data.Sqlite.dll' 'System.Data.Sqlite.dll'
Please refer to this post. I have become able to configure my web.config file
The application I am working inputs lot of data from file import and updates
I'm creating a class that will store data in a file and I need
SOLUTION Refer to my answer below: issues with form/iframe based file upload in Opera
I have file with binary data. This is specification: The SRTM data files have
I have a JavaScript application that works like this: Uploads a file, receives the

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.