[英]convert currency symbol to XML decimal entity reference within PHP 5.3.10
[英]Getting Symfony Doctrine Entity Manager within PHP Docker container / phpbrew for PHP 5.3.10
我正在嘗試使用PHP 5.3.10在Docker下運行Symfony命令。 當我到達像
class Data{
public function prepareData(){
echo 'before getContainer';
$em = $this->getContainer()->get('doctrine.orm.entity_manager')->getConnection();
echo 'after getContainer';
}
}
它無聲地失敗。
用於設置容器的docker命令是
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
在Docker容器中時,我將安裝mysql,然后可以登錄並查看本地系統上存在的數據庫。
我在Docker容器中運行的Symfony命令就像
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或教義相關的問題嗎?
我嘗試了其他一些Symfony CLI命令,並注意到有時通過Composer安裝的Doctrine供應商存儲庫中會出現致命錯誤。 經檢查后,便是使用PHP 5.4語法(方括號)初始化數組的地方。 因此,這當然在5.3容器中不起作用。 因此,我將doctrine/cache
, doctrine/common
和doctrine/orm
降級了,這些命令現在可以運行了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.