我試圖在Docker下使用PHP 5.3.10運行Symfony命令。當我得到像在PHP中獲取Symfony Doctrine Entity Manager Docker container/phpbrew for PHP 5.3.10
class Data{
public function prepareData(){
echo 'before getContainer';
$em = $this->getContainer()->get('doctrine.orm.entity_manager')->getConnection();
echo 'after getContainer';
}
}
它靜靜地失敗。
泊塢窗命令設置的容器是
docker run --network="host" -t -i -p 80:80 -v /srv/www/live/:/srv/www/live/ -v /var/run/mysqld/mysqld.sock:/var/run/mysqld/mysqld.sock bylexus/apache-php53 /bin/bash
當碼頭工人容器我安裝mysql,然後可以登錄,看看我的本地系統上存在的數據庫。
symfony的指令I的多克爾容器內運行就像
php app/console mytask:preparedata
從
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputArgument;
class PrepareDataCommand extends Command
{
protected function configure()
{
parent::configure();
$this->setName('mytask:preparedata');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->getHelper('Data')->prepareData();
}
}
執行該prepareData
功能。 'getContainer'之後'不會迴應,只是'getContainer'之前。日誌中沒有任何東西,Apache,MySQL或Symfony。
你有一個想法如何調試這個或如何獲得像它發生在Docker外的容器?
更新
我現在已經測試了使用phpbrew。它適用於PHP 5.6.30版本,但不適用於所需的PHP 5.3.10版本(停止在上述相同的$em = $this->getContainer
行)。奇怪的是,它也不適用於phpbrew中的PHP 7.0.3。它現在可能是PHP版本的Symfony或Doctrine相關問題嗎?