0
Symfony的2.8.7我在services.yml一個簡單的別名定義:服務容器別名僅適用於一定的環境
h4cc_alice_fixtures:
alias: h4cc_alice_fixtures.manager
這工作完全在DEV因爲在我AppKernel h4cc註冊:
public function registerBundles()
{
$bundles = [
//...
];
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
$bundles[] = new h4cc\AliceFixturesBundle\h4ccAliceFixturesBundle();
}
return $bundles;
}
在PROD現在我得到一個依賴注入錯誤,因爲當然h4cc_alice_fixtures.manager無法解析。
我想只在DEV和TEST中有h4ccAliceFixturesBundle,但目前我只有一個services.yml。
有沒有辦法只爲DEV和TEST定義別名?
UPDATE:
由於有這樣的:
my_service:
class: Acme\AcmeBundle\Services\MyService
arguments: [ '@tenant_user_service', '@?debug.stopwatch' ]
其中僅注入秒錶當應用程序處於調試模式...
我認爲有可能是現有的Alias也有類似的東西。
怎麼樣在service_dev.yml中配置dev服務並通過config_dev.yml包含它? – Muriano
謝謝,我已更新我的問題以澄清我的期望可能是什麼,但也許你是對的 – LBA