'symfony asset-component in controller: file not found

I'm using Symfony 5.3.9 and try to load a file into a Service-controller. I use the assets-component with emptyVersionStrategy.

my filesystem:

/assets/vorlagen/XXX.html

My Service-Controller-Code:

$package = new PathPackage('/assets/vorlagen', new EmptyVersionStrategy());
$template = $package->getUrl($anzeige->getTemplate()->getDatei());
$handle = file_get_contents($template);

The error-Message: Warning: file_get_contents(/assets/vorlagen/XXX.html): failed to open stream: No such file or directory



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source