I have a css file called 'style.css' and I want to load its content inside a controller. I didn't find any relevant solution when reading the official documentation (Cookbook included).
3 Answers
I found a simple solution if you have the path to the file then
$file = new SplFileInfo('/path/to/file.css', '', '');
and the method getContents does the magic
$file->getContents();
But you will have to include the class
use Symfony\Component\Finder\SplFileInfo;
is also part of the finder library, but you don't need to search for the file you want to read.
1 Comment
Azoel
It should be the correct answer