Symfony中的Url路径

Symfony中的Url路径,symfony,filepath,Symfony,Filepath,需要将数据保存在文本文件中。无法获取正确的文本文件路径。请建议 现在,我尝试使用以下代码$file_url=“{{asset('/temp_files/calender.txt')}”; $ourFileHandle=fopen($file_url,'w')或die(“无法打开文件1”); 但是没有得到确切的路径 像这样使用templating.helper.assets $this->container->get('templating.helper.assets')->g

需要将数据保存在文本文件中。无法获取正确的文本文件路径。请建议

现在,我尝试使用以下代码
$file_url=“{{asset('/temp_files/calender.txt')}”;
$ourFileHandle=fopen($file_url,'w')或die(“无法打开文件1”);


但是没有得到确切的路径

像这样使用templating.helper.assets

$this->container->get('templating.helper.assets')->getUrl('bundles/somename/other/calendar.txt')
其中bundles/somename存在于web/bundles文件夹中。如果web/bundles文件夹中没有任何内容,请运行以下命令:

php app/console assets:install ./web --symlink

上面列出的另一个文件夹将是您在捆绑包的Resources/public文件夹中创建的文件夹。

您要在哪里执行该代码?在你的控制器里?