ConfigFormatConverter.php
public function convertFile(SplFileInfo $file, $newFormat)
    {
        if (!$file->isFile()) {
            throw UnknownFileException::create($file->getRealPath());
        }
        $container = new ContainerBuilder(new ParameterBag());
        $loader = $this->loaderFactory->createFileLoader($file->getExtension(), $container, $file->getPath());
        $loader->load($file->getFilename());

        return $this->dumperFactory->createDumper($newFormat, $container)->dump();
    }
public function convertFile(SplFileInfo $file, $newFormat)
    {
        if (!$file->isFile()) {
            throw UnknownFileException::create($file->getRealPath());
        }
        $container = new ContainerBuilder(new ParameterBag());
        $loader = $this->loaderFactory->createFileLoader($file->getExtension(), $container, $file->getPath());
        $loader->load($file->getFilename());

        return $this->dumperFactory->createDumper($newFormat, $container)->dump();
    }
Convert a service config file from one format to another (xml, yml, etc)

@param  SplFileInfo                    $file      The file to convert
@param  string                         $newFormat Format to convert to, given as a file extension
@return string                         Converted config, returned as a raw string
@throws Exception\UnknownFileException