3
我需要保存一個文件在/web/import
的路徑,我問的是實現這個目標的最好方法。我在/Service/SyncController.php
定義的類,它從Controller
延伸:我可以在Symfony2的容器中使用「/ web」路徑嗎?
class SyncController extends Controller { ... }
那類被定義爲一個服務也:
sync.service:
class: PDI\PDOneBundle\Service\SyncController
arguments: ["@service_container", "@doctrine.orm.entity_manager", "@request_stack", "%kernel.root_dir%"]
我需要傳遞參數"%kernel.root_dir%"
才能訪問網絡路徑作爲$this->webRoot = realpath($rootDir . '/../web')
或我可以從@service_container
?爲了將文件保存在那裏,通往/web/import
的路徑的正確方法是?
我認爲'web'不Symfony的定義,因此你可能無法得到它的路徑。 –