get('kernel')->ge-6ren">
gpt4 book ai didi

symfony 4 : How to get "/public" from RootDir

转载 作者:行者123 更新时间:2023-12-04 00:25:29 26 4
gpt4 key购买 nike

我在 public 下有一张图片文件夹。
如何在 symfony4 中获取我的图像目录?
在 symfony 3 中,它相当于:

$webPath = $this->get('kernel')->getRootDir() . '/../web/';

最佳答案

你可以使用

$webPath = $this->get('kernel')->getProjectDir() . '/public/'; 

或者参数 %kernel.project_dir%
$container->getParameter('kernel.project_dir') . '/public/';

关于symfony 4 : How to get "/public" from RootDir,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48585265/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com