First of all: in the YAML service and parameter definitions, @ also refers to another service. This is why your code is not working.
In principle, you have two options. The first and easiest is to use the relative path in your services.yml packages and add it to your CSV class.
For instance:
# 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; } ... }
Another possibility is to make the CSV file custom with config.yml (see this article in the Symfony2 cookbook ) and insert a special placeholder in the configuration value that you replace in the 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 will look like this:
source share